From 5a9e45f9d84b55210922797a5540628c6f0e057f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 28 Jun 2013 04:22:22 -0600 Subject: [PATCH] Upgrade telepath --- src/app/atom.coffee | 2 +- src/app/edit-session.coffee | 8 ++++---- src/app/pane-axis.coffee | 13 ++++++------- src/app/pane-container.coffee | 8 ++++---- src/app/pane.coffee | 17 ++++++++--------- src/app/root-view.coffee | 2 +- vendor/telepath | 2 +- 7 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/app/atom.coffee b/src/app/atom.coffee index 948b5ef6f..965613cd7 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -270,7 +270,7 @@ window.atom = console.warn "Error parsing window state: #{windowStatePath}", error.stack, error windowState ?= {} - telepath.Document.fromObject(telepath.createSite(1), windowState) + telepath.Document.create(windowState, site: telepath.createSite(1)) saveWindowState: -> windowStateJson = JSON.stringify(@getWindowState().toObject()) diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 6d5379169..0209e30b5 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -45,7 +45,7 @@ class EditSession cursorScreenPosition = @state.getObject('cursorScreenPosition') else {@buffer, tabLength, softTabs, @softWrap} = optionsOrState - @state = telepath.Document.fromObject + @state = telepath.Document.create deserializer: 'EditSession' version: @constructor.version scrollTop: 0 @@ -75,12 +75,12 @@ class EditSession @displayBuffer.on 'grammar-changed', => @handleGrammarChange() - @state.observe ({key, value, site}) => + @state.observe ({key, newValue}) => switch key when 'scrollTop' - @trigger 'scroll-top-changed', value + @trigger 'scroll-top-changed', newValue when 'scrollLeft' - @trigger 'scroll-left-changed', value + @trigger 'scroll-left-changed', newValue getViewClass: -> require 'editor' diff --git a/src/app/pane-axis.coffee b/src/app/pane-axis.coffee index 467c6e405..427ac157f 100644 --- a/src/app/pane-axis.coffee +++ b/src/app/pane-axis.coffee @@ -15,16 +15,15 @@ class PaneAxis extends View @state = args[0] @state.get('children').each (child, index) => @addChild(deserialize(child), index, updateState: false) else - @state = telepath.Document.fromObject(deserializer: @className(), children: []) + @state = telepath.Document.create(deserializer: @className(), children: []) @addChild(child) for child in args - @state.get('children').observe ({index, value, type, site}) => + @state.get('children').observe ({index, inserted, removed, site}) => return if site is @state.site.id - switch type - when 'insert' - @addChild(deserialize(value), index, updateState: false) - when 'remove' - @removeChild(@children(":eq(#{index})").view(), updateState: false) + for childState in removed + @removeChild(@children(":eq(#{index})").view(), updateState: false) + for childState, i in inserted + @addChild(deserialize(childState), index + i, updateState: false) addChild: (child, index=@children().length, options={}) -> @insertAt(index, child) diff --git a/src/app/pane-container.coffee b/src/app/pane-container.coffee index 2a31aa5e8..d8365f41a 100644 --- a/src/app/pane-container.coffee +++ b/src/app/pane-container.coffee @@ -22,12 +22,12 @@ class PaneContainer extends View if @state? @setRoot(deserialize(@state.get('root')), updateState: false) else - @state = telepath.Document.fromObject(deserializer: 'PaneContainer') + @state = telepath.Document.create(deserializer: 'PaneContainer') - @state.observe ({key, value, type, site}) => + @state.observe ({key, newValue, site}) => return if site is @state.site.id - if key is 'root' and type is 'set' - @setRoot(deserialize(value), updateState: false) + if key is 'root' + @setRoot(deserialize(newValue), updateState: false) @destroyedItemStates = [] diff --git a/src/app/pane.coffee b/src/app/pane.coffee index 8b6471945..458c1b2b0 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -29,21 +29,20 @@ class Pane extends View @items = @state.get('items').map (item) -> deserialize(item) else @items = args - @state = telepath.Document.fromObject + @state = telepath.Document.create deserializer: 'Pane' items: @items.map (item) -> item.getState?() ? item.serialize() - @state.get('items').observe ({index, value, type, site}) => + @state.get('items').observe ({index, removed, inserted, site}) => return if site is @state.site.id - switch type - when 'insert' - @addItem(deserialize(value), index, updateState: false) - when 'remove' - @removeItemAtIndex(index, updateState: false) + for itemState in removed + @removeItemAtIndex(index, updateState: false) + for itemState, i in inserted + @addItem(deserialize(itemState), index + i, updateState: false) - @state.observe ({key, value, site}) => + @state.observe ({key, newValue, site}) => return if site is @state.site.id - @showItemForUri(value) if key is 'activeItemUri' + @showItemForUri(newValue) if key is 'activeItemUri' @viewsByClassName = {} if activeItemUri = @state.get('activeItemUri') diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 4218256d6..0af310717 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -41,7 +41,7 @@ class RootView extends View if state instanceof telepath.Document @state = state else - @state = telepath.Document.fromObject(_.extend(version: RootView.version, deserializer: 'RootView', panes: @panes.serialize(), state)) + @state = telepath.Document.create(_.extend({version: RootView.version, deserializer: 'RootView', panes: @panes.serialize()}, state)) @on 'focus', (e) => @handleFocus(e) @subscribe $(window), 'focus', (e) => diff --git a/vendor/telepath b/vendor/telepath index 87d078f94..3b465ef7e 160000 --- a/vendor/telepath +++ b/vendor/telepath @@ -1 +1 @@ -Subproject commit 87d078f948a728b1e395fc80f37adda522461f87 +Subproject commit 3b465ef7e08c188621e3a30817650fbea38d3656