diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2016-01-25 13:14:06 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 23:47:57 +0100 |
commit | 15c4ed6bebdeb277c24bd92dab5bba900fc90de4 (patch) | |
tree | 0171f769ecda89185885ad0a792fdb570913962a /src/web/js/stores/MenuStore.js | |
parent | bootstraping right panel (diff) | |
download | newspipe-15c4ed6bebdeb277c24bd92dab5bba900fc90de4.tar.gz newspipe-15c4ed6bebdeb277c24bd92dab5bba900fc90de4.tar.bz2 newspipe-15c4ed6bebdeb277c24bd92dab5bba900fc90de4.zip |
redoing constant, handling read / unread in menu, removing bad optim for loading articles
Diffstat (limited to 'src/web/js/stores/MenuStore.js')
-rw-r--r-- | src/web/js/stores/MenuStore.js | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js index 6809d8b0..ecf32499 100644 --- a/src/web/js/stores/MenuStore.js +++ b/src/web/js/stores/MenuStore.js @@ -1,5 +1,5 @@ var JarrDispatcher = require('../dispatcher/JarrDispatcher'); -var MenuActionTypes = require('../constants/JarrConstants').MenuActionTypes; +var ActionTypes = require('../constants/JarrConstants'); var EventEmitter = require('events').EventEmitter; var CHANGE_EVENT = 'change_menu'; var assign = require('object-assign'); @@ -41,25 +41,50 @@ var MenuStore = assign({}, EventEmitter.prototype, { MenuStore.dispatchToken = JarrDispatcher.register(function(action) { switch(action.type) { - case MenuActionTypes.RELOAD_MENU: + case ActionTypes.RELOAD_MENU: MenuStore._datas['categories'] = action.categories; MenuStore._datas['feed_in_error'] = action.feed_in_error; MenuStore._datas['all_unread_count'] = action.all_unread_count; MenuStore.emitChange(); break; - case MenuActionTypes.PARENT_FILTER: + case ActionTypes.PARENT_FILTER: MenuStore.setActive(action.filter_type, action.filter_id); break; - case MenuActionTypes.MENU_FILTER: + case ActionTypes.MENU_FILTER: MenuStore.setFilter(action.filter); break; - case MenuActionTypes.MENU_FILTER: + case ActionTypes.MENU_FILTER: MenuStore.setFilter(action.filter); break; - case MenuActionTypes.MENU_FILTER: + case ActionTypes.MENU_FILTER: MenuStore.setFilter(action.filter); break; + case ActionTypes.CHANGE_ATTR: + 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; + } + } + } + if(action.value) { + MenuStore._datas.categories[i].unread -= 1; + } else { + MenuStore._datas.categories[i].unread += 1; + } + MenuStore.emitChange(); + break; + } + } + break; default: // do nothing } |