diff options
Diffstat (limited to 'src/web/js/stores')
-rw-r--r-- | src/web/js/stores/MenuStore.js | 25 | ||||
-rw-r--r-- | src/web/js/stores/MiddlePanelStore.js | 46 |
2 files changed, 41 insertions, 30 deletions
diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js index 49c61bc1..1cbbbda7 100644 --- a/src/web/js/stores/MenuStore.js +++ b/src/web/js/stores/MenuStore.js @@ -17,6 +17,7 @@ var MenuStore = assign({}, EventEmitter.prototype, { setFilter: function(value) { if(this._datas.filter != value) { this._datas.filter = value; + this._datas.all_folded = null; this.emitChange(); } }, @@ -24,12 +25,10 @@ var MenuStore = assign({}, EventEmitter.prototype, { if(this._datas.active_id != value || this._datas.active_type != type) { this._datas.active_type = type; this._datas.active_id = value; + this._datas.all_folded = null; this.emitChange(); } }, - readFeedArticle: function(feed_id) { - // TODO - }, emitChange: function() { this.emit(CHANGE_EVENT); }, @@ -53,6 +52,7 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { MenuStore._datas['error_threshold'] = action.error_threshold; MenuStore._datas['crawling_method'] = action.crawling_method; MenuStore._datas['all_unread_count'] = action.all_unread_count; + MenuStore._datas.all_folded = null; MenuStore.emitChange(); break; case ActionTypes.PARENT_FILTER: @@ -81,10 +81,10 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { MenuStore._datas.categories[cat_id].unread += new_unread[feed_id]; } if(changed) { + MenuStore._datas.all_folded = null; MenuStore.emitChange(); } } - break; case ActionTypes.MENU_FILTER: MenuStore.setFilter(action.filter); @@ -98,18 +98,35 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) { MenuStore._datas.categories[article.category_id].unread += val; MenuStore._datas.feeds[article.feed_id].unread += val; }); + MenuStore._datas.all_folded = null; MenuStore.emitChange(); break; case ActionTypes.LOAD_ARTICLE: if(!action.was_read_before) { MenuStore._datas.categories[action.article.category_id].unread -= 1; MenuStore._datas.feeds[action.article.feed_id].unread -= 1; + MenuStore._datas.all_folded = null; MenuStore.emitChange(); } break; case ActionTypes.TOGGLE_MENU_FOLD: MenuStore._datas.all_folded = action.all_folded; MenuStore.emitChange(); + break; + case ActionTypes.MARK_ALL_AS_READ: + action.articles.map(function(art) { + if(!art.read) { + MenuStore._datas.feeds[art.feed_id].unread -= 1; + if(art.category_id) { + MenuStore._datas.categories[art.category_id].unread -= 1; + + } + } + }); + + MenuStore._datas.all_folded = null; + MenuStore.emitChange(); + break; default: // do nothing } diff --git a/src/web/js/stores/MiddlePanelStore.js b/src/web/js/stores/MiddlePanelStore.js index 4a5efd00..c554f929 100644 --- a/src/web/js/stores/MiddlePanelStore.js +++ b/src/web/js/stores/MiddlePanelStore.js @@ -82,20 +82,18 @@ var MiddlePanelStore = assign({}, EventEmitter.prototype, { MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) { var changed = false; - switch(action.type) { - case ActionTypes.RELOAD_MIDDLE_PANEL: - changed = MiddlePanelStore.registerFilter(action); - changed = MiddlePanelStore.setArticles(action.articles) || changed; - break; - case ActionTypes.PARENT_FILTER: - changed = MiddlePanelStore.registerFilter(action); - changed = MiddlePanelStore.setArticles(action.articles) || changed; - break; - case ActionTypes.MIDDLE_PANEL_FILTER: - changed = MiddlePanelStore.registerFilter(action); - changed = MiddlePanelStore.setArticles(action.articles) || changed; - break; - case ActionTypes.CHANGE_ATTR: + if (action.type == ActionTypes.RELOAD_MIDDLE_PANEL + || action.type == ActionTypes.PARENT_FILTER + || action.type == ActionTypes.MIDDLE_PANEL_FILTER) { + changed = MiddlePanelStore.registerFilter(action); + changed = MiddlePanelStore.setArticles(action.articles) || changed; + } else if (action.type == ActionTypes.MARK_ALL_AS_READ) { + changed = MiddlePanelStore.registerFilter(action); + for(var i in action.articles) { + action.articles[i].read = true; + } + changed = MiddlePanelStore.setArticles(action.articles) || changed; + } else if (action.type == ActionTypes.CHANGE_ATTR) { var attr = action.attribute; var val = action.value_bool; action.articles.map(function(article) { @@ -112,19 +110,15 @@ MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) { } } }); - break; - case ActionTypes.LOAD_ARTICLE: - changed = true; - MiddlePanelStore._datas.selected_article = action.article.id; - for (var i in MiddlePanelStore._datas.articles) { - if(MiddlePanelStore._datas.articles[i].article_id == action.article.id) { - MiddlePanelStore._datas.articles[i].read = true; - break; - } + } else if (action.type == ActionTypes.LOAD_ARTICLE) { + changed = true; + MiddlePanelStore._datas.selected_article = action.article.id; + for (var i in MiddlePanelStore._datas.articles) { + if(MiddlePanelStore._datas.articles[i].article_id == action.article.id) { + MiddlePanelStore._datas.articles[i].read = true; + break; } - break; - default: - // pass + } } if(changed) {MiddlePanelStore.emitChange();} }); |