From 177d4e530cac216c976598a242b26fd692f4c8af Mon Sep 17 00:00:00 2001 From: Galen Wolfe-Pauly Date: Wed, 17 Jun 2015 18:30:19 -0700 Subject: [PATCH] fixed arvo spinner --- .../src/js/components/ListComponent.coffee | 10 +++-- base/pub/tree/src/js/main.js | 42 ++++++++----------- base/pub/tree/src/js/stores/TreeStore.coffee | 16 +++++-- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/base/pub/tree/src/js/components/ListComponent.coffee b/base/pub/tree/src/js/components/ListComponent.coffee index d4ddbad115..783883590f 100644 --- a/base/pub/tree/src/js/components/ListComponent.coffee +++ b/base/pub/tree/src/js/components/ListComponent.coffee @@ -15,13 +15,14 @@ module.exports = recl path:path } - componentDidMount: -> - TreeStore.addChangeListener @_onChangeStore + _onChangeStore: -> + @setState @stateFromStore() + + componentWillUnmount: -> + TreeStore.removeChangeListener @_onChangeStore getInitialState: -> @stateFromStore() - _onChangeStore: -> @setState @stateFromStore() - getCont: -> cont = true keys = _.keys @state.tree @@ -32,6 +33,7 @@ module.exports = recl componentDidMount: -> cont = @getCont() + TreeStore.addChangeListener @_onChangeStore if not @state.tree or _.keys(@state.tree).length is 0 or not cont TreeActions.getPath @state.path,"snip" diff --git a/base/pub/tree/src/js/main.js b/base/pub/tree/src/js/main.js index e9e5042931..c6c2b7b8d4 100644 --- a/base/pub/tree/src/js/main.js +++ b/base/pub/tree/src/js/main.js @@ -71,7 +71,6 @@ module.exports = { }; - },{"../dispatcher/Dispatcher.coffee":8,"../persistence/TreePersistence.coffee":13}],2:[function(require,module,exports){ var TreeActions, TreeStore, a, div, recl, ref; @@ -294,7 +293,6 @@ module.exports = recl({ }); - },{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14}],3:[function(require,module,exports){ var TreeActions, TreeStore, div, input, load, recl, ref, textarea; @@ -359,7 +357,6 @@ module.exports = recl({ }); - },{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14,"./LoadComponent.coffee":7}],4:[function(require,module,exports){ var div, recl, ref, textarea; @@ -383,7 +380,6 @@ module.exports = recl({ }); - },{}],5:[function(require,module,exports){ var TreeActions, TreeStore, a, div, hr, li, recl, ref, ul; @@ -450,7 +446,6 @@ module.exports = recl({ }); - },{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14}],6:[function(require,module,exports){ var TreeActions, TreeStore, a, div, h1, li, load, recl, ref, ul; @@ -474,15 +469,15 @@ module.exports = recl({ path: path }; }, - componentDidMount: function() { - return TreeStore.addChangeListener(this._onChangeStore); + _onChangeStore: function() { + return this.setState(this.stateFromStore()); + }, + componentWillUnmount: function() { + return TreeStore.removeChangeListener(this._onChangeStore); }, getInitialState: function() { return this.stateFromStore(); }, - _onChangeStore: function() { - return this.setState(this.stateFromStore()); - }, getCont: function() { var cont, i, k, keys, len; cont = true; @@ -501,6 +496,7 @@ module.exports = recl({ componentDidMount: function() { var cont; cont = this.getCont(); + TreeStore.addChangeListener(this._onChangeStore); if (!this.state.tree || _.keys(this.state.tree).length === 0 || !cont) { return TreeActions.getPath(this.state.path, "snip"); } @@ -545,7 +541,6 @@ module.exports = recl({ }); - },{"../actions/TreeActions.coffee":1,"../stores/TreeStore.coffee":14,"./LoadComponent.coffee":7}],7:[function(require,module,exports){ var div, input, recl, ref, textarea; @@ -583,7 +578,6 @@ module.exports = recl({ }); - },{}],8:[function(require,module,exports){ var Dispatcher; @@ -605,7 +599,6 @@ module.exports = _.extend(new Dispatcher(), { }); - },{"flux":10}],9:[function(require,module,exports){ var rend; @@ -765,7 +758,6 @@ $(function() { }); - },{"./actions/TreeActions.coffee":1,"./components/AnchorComponent.coffee":2,"./components/BodyComponent.coffee":3,"./components/CodeMirror.coffee":4,"./components/KidsComponent.coffee":5,"./components/ListComponent.coffee":6,"./persistence/TreePersistence.coffee":13}],10:[function(require,module,exports){ /** * Copyright (c) 2014-2015, Facebook, Inc. @@ -1106,7 +1098,6 @@ module.exports = { }; - },{"../actions/TreeActions.coffee":1}],14:[function(require,module,exports){ var EventEmitter, MessageDispatcher, TreeStore, _cont, _curr, _load, _snip, _tree; @@ -1192,15 +1183,19 @@ TreeStore = _.extend(EventEmitter.prototype, { loadSnip: function(path, snip) { var k, results, v; this.mergePathToTree(path, _.pluck(snip, "name")); - results = []; - for (k in snip) { - v = snip[k]; - results.push(_snip[path + "/" + v.name] = { - head: window.tree.reactify(v.body.head), - body: window.tree.reactify(v.body.body) - }); + if ((snip != null ? snip.length : void 0) !== 0) { + results = []; + for (k in snip) { + v = snip[k]; + results.push(_snip[path + "/" + v.name] = { + head: window.tree.reactify(v.body.head), + body: window.tree.reactify(v.body.body) + }); + } + return results; + } else { + return _cont[path] = window.tree.reactify("React.createElement ('div', {}, [ React.createElement('h1', {}, 'Error: Empty path'), React.createElement('div', {}, [ React.createElement('pre', {}, '" + (this.getCurr()) + "'), React.createElement('span', {}, 'is either empty or does not exist.') ]) ])"); } - return results; }, loadKids: function(path, kids) { var k, results, v; @@ -1320,7 +1315,6 @@ TreeStore.dispatchToken = MessageDispatcher.register(function(payload) { module.exports = TreeStore; - },{"../dispatcher/Dispatcher.coffee":8,"events":15}],15:[function(require,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // diff --git a/base/pub/tree/src/js/stores/TreeStore.coffee b/base/pub/tree/src/js/stores/TreeStore.coffee index 284f493d19..b0e147abe1 100644 --- a/base/pub/tree/src/js/stores/TreeStore.coffee +++ b/base/pub/tree/src/js/stores/TreeStore.coffee @@ -54,10 +54,18 @@ TreeStore = _.extend EventEmitter.prototype, { loadSnip: (path,snip) -> @mergePathToTree path,_.pluck(snip,"name") - for k,v of snip - _snip[path+"/"+v.name] = - head: window.tree.reactify v.body.head - body: window.tree.reactify v.body.body + if snip?.length isnt 0 + for k,v of snip + _snip[path+"/"+v.name] = + head: window.tree.reactify v.body.head + body: window.tree.reactify v.body.body + else + _cont[path] = window.tree.reactify "React.createElement ('div', {}, [ + React.createElement('h1', {}, 'Error: Empty path'), + React.createElement('div', {}, [ + React.createElement('pre', {}, '#{@getCurr()}'), + React.createElement('span', {}, 'is either empty or does not exist.') + ]) ])" loadKids: (path,kids) -> @mergePathToTree path,_.pluck(kids,"name")