actually fix async maybe?

This commit is contained in:
Anton Dyudin 2015-09-23 17:17:09 -07:00
parent 3a1170cedd
commit f77ffac57c
3 changed files with 20 additions and 12 deletions

View File

@ -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 = {}

View File

@ -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);
}
}
}
}

View File

@ -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