mirror of
https://github.com/atom/atom.git
synced 2026-02-06 20:55:33 -05:00
Unify root view state with window state
This commit is contained in:
@@ -179,17 +179,6 @@ _.extend atom,
|
||||
toggleFullScreen: ->
|
||||
@sendMessageToBrowserProcess('toggleFullScreen')
|
||||
|
||||
getRootViewStateForPath: (path) ->
|
||||
if json = localStorage[path]
|
||||
JSON.parse(json)
|
||||
|
||||
setRootViewStateForPath: (path, state) ->
|
||||
return unless path
|
||||
if state?
|
||||
localStorage[path] = JSON.stringify(state)
|
||||
else
|
||||
delete localStorage[path]
|
||||
|
||||
sendMessageToBrowserProcess: (name, data=[], callbacks) ->
|
||||
messageId = messageIdCounter++
|
||||
data.unshift(messageId)
|
||||
@@ -209,12 +198,17 @@ _.extend atom,
|
||||
windowState
|
||||
|
||||
getWindowState: (keyPath) ->
|
||||
windowState = JSON.parse($native.getWindowState())
|
||||
inMemoryState = $native.getWindowState()
|
||||
inMemoryState = null unless inMemoryState.length > 0
|
||||
windowState = JSON.parse(inMemoryState ? localStorage[window.location.params.pathToOpen] ? '{}')
|
||||
if keyPath
|
||||
_.valueForKeyPath(windowState, keyPath)
|
||||
else
|
||||
windowState
|
||||
|
||||
saveWindowState: ->
|
||||
localStorage[@getPathToOpen()] = JSON.stringify(@getWindowState())
|
||||
|
||||
update: ->
|
||||
@sendMessageToBrowserProcess('update')
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ window.startup = ->
|
||||
keymap.loadBundledKeymaps()
|
||||
atom.loadThemes()
|
||||
atom.loadPackages()
|
||||
buildProjectAndRootView()
|
||||
deserializeWindowState()
|
||||
atom.activatePackages()
|
||||
keymap.loadUserKeymaps()
|
||||
atom.requireUserInitScript()
|
||||
@@ -66,9 +66,9 @@ window.startup = ->
|
||||
window.shutdown = ->
|
||||
return if not project and not rootView
|
||||
atom.setWindowState('pathToOpen', project.getPath())
|
||||
atom.setRootViewStateForPath project.getPath(),
|
||||
project: project.serialize()
|
||||
rootView: rootView.serialize()
|
||||
atom.setWindowState('project', project.serialize())
|
||||
atom.setWindowState('rootView', rootView.serialize())
|
||||
atom.saveWindowState()
|
||||
rootView.deactivate()
|
||||
project.destroy()
|
||||
git?.destroy()
|
||||
@@ -91,13 +91,15 @@ window.handleWindowEvents = ->
|
||||
$(window).on 'blur', -> $("body").addClass('is-blurred')
|
||||
$(window).command 'window:close', => confirmClose()
|
||||
|
||||
window.buildProjectAndRootView = ->
|
||||
window.deserializeWindowState = ->
|
||||
RootView = require 'root-view'
|
||||
Project = require 'project'
|
||||
Git = require 'git'
|
||||
|
||||
pathToOpen = atom.getPathToOpen()
|
||||
windowState = atom.getRootViewStateForPath(pathToOpen) ? {}
|
||||
|
||||
windowState = atom.getWindowState()
|
||||
|
||||
window.project = deserialize(windowState.project) ? new Project(pathToOpen)
|
||||
window.rootView = deserialize(windowState.rootView) ? new RootView
|
||||
|
||||
|
||||
Reference in New Issue
Block a user