aboutsummaryrefslogtreecommitdiff
path: root/src/web/js/stores
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-03-22 14:30:54 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-03-22 14:30:54 +0100
commit3d199ce8955c035a5a1bc4569058e2f84ef9cfe0 (patch)
treee8bb7f02b6b4bae283807577123b851e66eb4bc4 /src/web/js/stores
parentfix... (diff)
downloadnewspipe-3d199ce8955c035a5a1bc4569058e2f84ef9cfe0.tar.gz
newspipe-3d199ce8955c035a5a1bc4569058e2f84ef9cfe0.tar.bz2
newspipe-3d199ce8955c035a5a1bc4569058e2f84ef9cfe0.zip
fixes
Diffstat (limited to 'src/web/js/stores')
-rw-r--r--src/web/js/stores/MenuStore.js19
-rw-r--r--src/web/js/stores/MiddlePanelStore.js46
2 files changed, 35 insertions, 30 deletions
diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js
index 9686ff4a..1cbbbda7 100644
--- a/src/web/js/stores/MenuStore.js
+++ b/src/web/js/stores/MenuStore.js
@@ -29,9 +29,6 @@ var MenuStore = assign({}, EventEmitter.prototype, {
this.emitChange();
}
},
- readFeedArticle: function(feed_id) {
- // TODO
- },
emitChange: function() {
this.emit(CHANGE_EVENT);
},
@@ -88,7 +85,6 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) {
MenuStore.emitChange();
}
}
-
break;
case ActionTypes.MENU_FILTER:
MenuStore.setFilter(action.filter);
@@ -116,6 +112,21 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) {
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();}
});
bgstack15