         itemTxt         = if itemLen is 1 then "file" else "files"
         formattedDate   = dateFormat date.setTime(sessionId.split("_")[1]), "dd mmm yyyy - HH:MM"
         items["#{formattedDate} (#{itemLen} #{itemTxt})"] =
-          callback: => @emit "SessionItemClicked", sessionItems
+          callback: => @getDelegate().emit "SessionItemClicked", sessionItems
 
     items.separator = type: "separator"
 

  updateSession: ->
    if @isSessionEnabled
      @fetchStorage (data) =>
        @getDelegate().emit 'UpdateSessionData', @panes, data

  restoreSession: (data, pane) ->
    return if data.latestSessions.length is 0
    @getDelegate().emit "SessionListCreated", pane, @createSessionList data

  createSessionList: (data) ->
    items = @createSessionItems data
    button = new KDButtonViewWithMenu
      title    : "Sessions"
      cssClass : "editor-button ace-session-button"
      menu     : => items

    return button

  createSessionItems: (data) ->
    items      = {}
    delegate   = @getDelegate()
    date       = new Date()

    data.latestSessions.forEach (sessionId, i) =>
      isSessionActive = yes for aceApp in appManager.appControllers.Ace when aceApp.getView().id is sessionId

      isSessionActive = yes for aceApp in appManager.appControllers.Ace when aceApp.getView().id is sessionId
      unless isSessionActive
        sessionItems = data[sessionId]
        sessionItems.forEach (path, i) =>
          if fileCount < 10
            filePath = path.replace("/home/#{KD.whoami().profile.nickname}", "~")
            items[filePath] = callback: => @getDelegate().emit "SessionItemClicked", [path]
            fileCount++

    return items
