diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2016-01-28 22:47:36 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-28 22:47:36 +0100 |
commit | 8e942f6f5695c4788328b4959527b30ff31e771d (patch) | |
tree | 1d6caa3d4b1d102ed804215d21bad8a04f9a00ff /src/web/js/stores | |
parent | slight redo of middle panel (diff) | |
download | newspipe-8e942f6f5695c4788328b4959527b30ff31e771d.tar.gz newspipe-8e942f6f5695c4788328b4959527b30ff31e771d.tar.bz2 newspipe-8e942f6f5695c4788328b4959527b30ff31e771d.zip |
redoing menu, sorting in place and not in python
Diffstat (limited to 'src/web/js/stores')
-rw-r--r-- | src/web/js/stores/MenuStore.js | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js index d98495f5..6921ae1c 100644 --- a/src/web/js/stores/MenuStore.js +++ b/src/web/js/stores/MenuStore.js @@ -6,7 +6,8 @@ var assign = require('object-assign'); var MenuStore = assign({}, EventEmitter.prototype, { - _datas: {filter: 'all', categories: [], active_type: null, active_id: null, + _datas: {filter: 'all', feeds: {}, categories: {}, + active_type: null, active_id: null, all_unread_count: 0, feed_in_error: false}, getAll: function() { return this._datas; @@ -42,6 +43,7 @@ var MenuStore = assign({}, EventEmitter.prototype, { MenuStore.dispatchToken = JarrDispatcher.register(function(action) { switch(action.type) { case ActionTypes.RELOAD_MENU: + MenuStore._datas['feeds'] = action.feeds; MenuStore._datas['categories'] = action.categories; MenuStore._datas['feed_in_error'] = action.feed_in_error; MenuStore._datas['all_unread_count'] = action.all_unread_count; @@ -65,19 +67,8 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { } 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; - } - } + MenuStore._datas.categories[article.category_id].unread += val; + MenuStore._datas.feeds[article.feed_id].unread += val; }); MenuStore.emitChange(); break; |