<commit_before>class CollaborativePanel extends Panel

  constructor: (options = {}, data) ->

    super options, data

    workspace      = @getDelegate()
    panesLength    = @getOptions().panes.length
    createadPanes  = []

    @on "NewPaneCreated", (pane) =>
      createadPanes.push pane

      if createadPanes.length is panesLength
        @getDelegate().emit "AllPanesAddedToPanel", @, createadPanes

    log "i've created new panes with these keys", @getOptions().sessionKeys

  createPane: (paneOptions, targetContainer) ->
    PaneClass              = @getPaneClass paneOptions.type
    paneOptions.delegate   = @
    paneOptions.sessionKey = @getOptions().sessionKeys[@panes.length]  if @getOptions().sessionKeys
    isJoinedASession       = !!paneOptions.sessionKey

    if isJoinedASession and paneOptions.type is "terminal"
      PaneClass = CollaborativeClientTerminalPane

    pane = new PaneClass paneOptions

    targetContainer.addSubView pane
    @panes.push pane
    @emit "NewPaneCreated", pane


CollaborativePanel::EditorPaneClass   = CollaborativeEditorPane
CollaborativePanel::TerminalPaneClass = CollaborativeTerminalPane
CollaborativePanel::VideoPaneClass    = VideoPane
CollaborativePanel::PreviewPaneClass  = PreviewPane<commit_msg>Workspace: Added amIHost method to check user joined a session or not.<commit_after>class CollaborativePanel extends Panel

  constructor: (options = {}, data) ->

    super options, data

    workspace      = @getDelegate()
    panesLength    = @getOptions().panes.length
    createadPanes  = []

    @on "NewPaneCreated", (pane) =>
      createadPanes.push pane

      if createadPanes.length is panesLength
        @getDelegate().emit "AllPanesAddedToPanel", @, createadPanes

    log "i've created new panes with these keys", @getOptions().sessionKeys

  createPane: (paneOptions, targetContainer) ->
    PaneClass              = @getPaneClass paneOptions.type
    paneOptions.delegate   = @
    paneOptions.sessionKey = @getOptions().sessionKeys[@panes.length]  if @getOptions().sessionKeys
    isJoinedASession       = !!paneOptions.sessionKey and not @amIHost paneOptions.sessionKey

    if isJoinedASession then log "#{KD.nick()} is joined a session"
    else log "#{KD.nick()} created a session"


    pane = new PaneClass paneOptions

    targetContainer.addSubView pane
    @panes.push pane
    @emit "NewPaneCreated", pane

  amIHost: (sessionKey) ->
    return  no unless sessionKey
    [sessionOwner] = sessionKey.split ":"
    return sessionOwner == KD.nick()

CollaborativePanel::EditorPaneClass   = CollaborativeEditorPane
CollaborativePanel::TerminalPaneClass = CollaborativeTerminalPane
CollaborativePanel::VideoPaneClass    = VideoPane
CollaborativePanel::PreviewPaneClass  = PreviewPane
{'fraction_non_alphanumeric': 0.0891053391053391, 'fraction_numerical': 0.0, 'mean_word_length': 3.9253996447602133, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5034622', 'n_tokens_mistral': 827, 'n_tokens_neox': 777, 'n_words': 184}