Move management of destroyedItemUris to Workspace model

This commit is contained in:
Nathan Sobo
2014-01-13 18:26:00 -07:00
parent a8ddc530a2
commit 27c03ae3f3
2 changed files with 12 additions and 15 deletions

View File

@@ -44,7 +44,8 @@ class WorkspaceView extends View
Serializable.includeInto(this)
Delegator.includeInto(this)
@delegatesProperty 'fullScreen', toProperty: 'model'
@delegatesProperty 'fullScreen', 'destroyedItemUris', toProperty: 'model'
@delegatesMethods 'itemOpened', toProperty: 'model'
@version: 4
@@ -74,9 +75,6 @@ class WorkspaceView extends View
@panes.replaceWith(panes)
@panes = panes
@destroyedItemUris = []
@subscribe @model, 'pane-item-destroyed', @onPaneItemDestroyed
@updateTitle()
@on 'focus', (e) => @handleFocus(e)
@@ -358,17 +356,7 @@ class WorkspaceView extends View
editorView.remove() for editorView in @getEditorViews()
super
# Private: Adds the destroyed item's uri to the list of items to reopen.
onPaneItemDestroyed: (item) =>
if uri = item.getUri?()
@destroyedItemUris.push(uri)
# Public: Reopens the last-closed item uri if it hasn't already been reopened.
reopenItemSync: ->
if uri = @destroyedItemUris.pop()
@openSync(uri)
# Private: Removes the item's uri from the list of potential items to reopen.
itemOpened: (item) ->
if uri = item.getUri?()
_.remove(@destroyedItemUris, uri)

View File

@@ -1,3 +1,4 @@
{remove} = require 'underscore-plus'
{Model} = require 'theorist'
Serializable = require 'serializable'
PaneContainer = require './pane-container'
@@ -10,6 +11,7 @@ class Workspace extends Model
@properties
paneContainer: -> new PaneContainer
fullScreen: false
destroyedItemUris: -> []
constructor: ->
super
@@ -23,5 +25,12 @@ class Workspace extends Model
paneContainer: @paneContainer.serialize()
fullScreen: atom.isFullScreen()
# Private: Removes the item's uri from the list of potential items to reopen.
itemOpened: (item) ->
if uri = item.getUri?()
remove(@destroyedItemUris, uri)
# Private: Adds the destroyed item's uri to the list of items to reopen.
onPaneItemDestroyed: (item) =>
@emit 'pane-item-destroyed', item
if uri = item.getUri?()
@destroyedItemUris.push(uri)