diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 23:23:42 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-27 00:34:34 +0100 |
commit | f3578d10239ffa716450c0089bcbc8d2826f59fd (patch) | |
tree | dd5a35e6ac3b953bd00f635c0db106e5081570d5 /src/web/js/stores/MenuStore.js | |
parent | optim on filter, not rerendering (diff) | |
download | newspipe-f3578d10239ffa716450c0089bcbc8d2826f59fd.tar.gz newspipe-f3578d10239ffa716450c0089bcbc8d2826f59fd.tar.bz2 newspipe-f3578d10239ffa716450c0089bcbc8d2826f59fd.zip |
mark all as read button
Diffstat (limited to 'src/web/js/stores/MenuStore.js')
-rw-r--r-- | src/web/js/stores/MenuStore.js | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js index ecf32499..d98495f5 100644 --- a/src/web/js/stores/MenuStore.js +++ b/src/web/js/stores/MenuStore.js @@ -63,27 +63,23 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { if(action.attribute != 'read') { return; } - for(var i in MenuStore._datas.categories) { - if(MenuStore._datas.categories[i].id == action.category_id) { - for(var j in MenuStore._datas.categories[i].feeds) { - if(MenuStore._datas.categories[i].feeds[j].id == action.feed_id) { - if(action.value) { - MenuStore._datas.categories[i].feeds[j].unread -= 1; - } else { - MenuStore._datas.categories[i].feeds[j].unread += 1; - } + var val = action.value_num; + action.articles.map(function(article) { + for(var i in MenuStore._datas.categories) { + if(MenuStore._datas.categories[i].id == article.category_id) { + for(var j in MenuStore._datas.categories[i].feeds) { + if(MenuStore._datas.categories[i].feeds[j].id == article.feed_id) { + MenuStore._datas.categories[i].feeds[j].unread += val; + break; + } } + MenuStore._datas.categories[i].unread += val; + break; } - if(action.value) { - MenuStore._datas.categories[i].unread -= 1; - } else { - MenuStore._datas.categories[i].unread += 1; - } - MenuStore.emitChange(); - break; } - } + }); + MenuStore.emitChange(); break; default: // do nothing |