From c1cd51bbb8072997d6be849862f95285a958e1e5 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Thu, 20 Aug 2015 17:20:48 -0700 Subject: [PATCH] update properly --- pub/work/src/js/main.js | 8 ++++++-- pub/work/src/js/stores/WorkStore.coffee | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pub/work/src/js/main.js b/pub/work/src/js/main.js index b313b4cbf..4cff94f14 100644 --- a/pub/work/src/js/main.js +++ b/pub/work/src/js/main.js @@ -1338,12 +1338,16 @@ WorkStore = assign({}, EventEmitter.prototype, { return this.removeListener("change", cb); }, getData: function(arg) { - var _tasks, i, id, len, sort, tasks; + var _tasks, got, i, id, j, len, sort, tasks; sort = arg.sort, tasks = arg.tasks; _tasks = _.clone(tasks); - for (i = 0, len = _list.length; i < len; i++) { + for (i = j = 0, len = _list.length; j < len; i = ++j) { id = _list[i].id; + if (!(got = _tasks[id])) { + continue; + } delete _tasks[id]; + _list[i] = this.itemFromData(got, i); } return sort.map((function(_this) { return function(k, index) { diff --git a/pub/work/src/js/stores/WorkStore.coffee b/pub/work/src/js/stores/WorkStore.coffee index 0cdf7edd8..25007bee5 100644 --- a/pub/work/src/js/stores/WorkStore.coffee +++ b/pub/work/src/js/stores/WorkStore.coffee @@ -70,8 +70,9 @@ WorkStore = assign {},EventEmitter.prototype,{ getData: ({sort,tasks})-> _tasks = _.clone tasks - for {id} in _list + for {id},i in _list when got = _tasks[id] delete _tasks[id] + _list[i] = @itemFromData got,i sort.map (k,index)=> if _tasks[k] @newItem {item:_tasks[k],index}