From f77ffac57cbb99119385d030dc61b53c4c24ab00 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Wed, 23 Sep 2015 17:17:09 -0700 Subject: [PATCH] actually fix async maybe? --- pub/tree/src/js/components/Async.coffee | 4 ++-- pub/tree/src/js/main.js | 20 +++++++++++++------- pub/tree/src/js/stores/TreeStore.coffee | 8 +++++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pub/tree/src/js/components/Async.coffee b/pub/tree/src/js/components/Async.coffee index 4eb41a21c..83593d7e1 100644 --- a/pub/tree/src/js/components/Async.coffee +++ b/pub/tree/src/js/components/Async.coffee @@ -36,8 +36,8 @@ module.exports = (queries, Child, load=_load)-> recl request = {} for k of _queries when k isnt 'kids' request[k] = _queries[k] unless have[k] isnt undefined - if _queries.kids? and have.kids? - if _.isEmpty have.kids + if _queries.kids? + if not have.kids? request.kids = _queries.kids else request.kids = {} diff --git a/pub/tree/src/js/main.js b/pub/tree/src/js/main.js index 44b20710b..ed112028a 100644 --- a/pub/tree/src/js/main.js +++ b/pub/tree/src/js/main.js @@ -356,8 +356,8 @@ module.exports = function(queries, Child, load) { } } } - if ((_queries.kids != null) && (have.kids != null)) { - if (_.isEmpty(have.kids)) { + if (_queries.kids != null) { + if (have.kids == null) { request.kids = _queries.kids; } else { request.kids = {}; @@ -1707,11 +1707,17 @@ TreeStore = _.extend(EventEmitter.prototype, { } data[k] = have[k]; } - if (query.kids && !have.EMPTY) { - data.kids = {}; - for (k in tree) { - sub = tree[k]; - data.kids[k] = this.fulfillAt(sub, path + "/" + k, query.kids); + if (query.kids) { + if (have.EMPTY) { + data.kids = {}; + } else { + for (k in tree) { + sub = tree[k]; + if (data.kids == null) { + data.kids = {}; + } + data.kids[k] = this.fulfillAt(sub, path + "/" + k, query.kids); + } } } } diff --git a/pub/tree/src/js/stores/TreeStore.coffee b/pub/tree/src/js/stores/TreeStore.coffee index 105f0fa0a..a3205e828 100644 --- a/pub/tree/src/js/stores/TreeStore.coffee +++ b/pub/tree/src/js/stores/TreeStore.coffee @@ -26,9 +26,11 @@ TreeStore = _.extend EventEmitter.prototype, { for k,t of query when QUERIES[k] if t isnt QUERIES[k] then throw TypeError "Wrong query type: #{k}, '#{t}'" data[k] = have[k] - if query.kids and not have.EMPTY - data.kids = {} - for k,sub of tree + if query.kids + if have.EMPTY + data.kids = {} + else for k,sub of tree + data.kids ?= {} data.kids[k] = @fulfillAt sub, path+"/"+k, query.kids data unless _.isEmpty data