aboutsummaryrefslogtreecommitdiff
path: root/src/web/js/stores
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2016-01-25 13:14:06 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2016-01-26 23:47:57 +0100
commit15c4ed6bebdeb277c24bd92dab5bba900fc90de4 (patch)
tree0171f769ecda89185885ad0a792fdb570913962a /src/web/js/stores
parentbootstraping right panel (diff)
downloadnewspipe-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')
-rw-r--r--src/web/js/stores/MenuStore.js37
-rw-r--r--src/web/js/stores/MiddlePanelStore.js16
-rw-r--r--src/web/js/stores/RightPanelStore.js3
3 files changed, 41 insertions, 15 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
}
diff --git a/src/web/js/stores/MiddlePanelStore.js b/src/web/js/stores/MiddlePanelStore.js
index 201bebd1..12c2d6e8 100644
--- a/src/web/js/stores/MiddlePanelStore.js
+++ b/src/web/js/stores/MiddlePanelStore.js
@@ -1,6 +1,5 @@
var JarrDispatcher = require('../dispatcher/JarrDispatcher');
-var MiddlePanelActionTypes = require('../constants/JarrConstants').MiddlePanelActionTypes;
-var MenuActionTypes = require('../constants/JarrConstants').MenuActionTypes;
+var ActionTypes = require('../constants/JarrConstants');
var EventEmitter = require('events').EventEmitter;
var CHANGE_EVENT = 'change_middle_panel';
var assign = require('object-assign');
@@ -69,22 +68,22 @@ var MiddlePanelStore = assign({}, EventEmitter.prototype, {
MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) {
var changed = false;
switch(action.type) {
- case MiddlePanelActionTypes.RELOAD_MIDDLE_PANEL:
+ case ActionTypes.RELOAD_MIDDLE_PANEL:
MiddlePanelStore.setArticles(action.articles);
MiddlePanelStore.emitChange();
break;
- case MiddlePanelActionTypes.PARENT_FILTER:
+ case ActionTypes.PARENT_FILTER:
changed = MiddlePanelStore.setParentFilter(action.filter_type,
action.filter_id);
changed = MiddlePanelStore.setArticles(action.articles) || changed;
if(changed) {MiddlePanelStore.emitChange();}
break;
- case MiddlePanelActionTypes.MIDDLE_PANEL_FILTER:
+ case ActionTypes.MIDDLE_PANEL_FILTER:
changed = MiddlePanelStore.setFilter(action.filter);
changed = MiddlePanelStore.setArticles(action.articles) || changed;
if(changed) {MiddlePanelStore.emitChange();}
break;
- case MiddlePanelActionTypes.CHANGE_ATTR:
+ case ActionTypes.CHANGE_ATTR:
var id = action.article_id;
var attr = action.attribute;
var val = action.value;
@@ -92,7 +91,10 @@ MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) {
if(MiddlePanelStore._datas.articles[i].article_id == id) {
if (MiddlePanelStore._datas.articles[i][attr] != val) {
MiddlePanelStore._datas.articles[i][attr] = val;
- MiddlePanelStore.emitChange();
+ // avoiding redraw if not filter, display won't change anyway
+ if(MiddlePanelStore._datas.filter != 'all') {
+ MiddlePanelStore.emitChange();
+ }
}
break;
}
diff --git a/src/web/js/stores/RightPanelStore.js b/src/web/js/stores/RightPanelStore.js
index 0bca9f54..54df1c95 100644
--- a/src/web/js/stores/RightPanelStore.js
+++ b/src/web/js/stores/RightPanelStore.js
@@ -1,6 +1,5 @@
var JarrDispatcher = require('../dispatcher/JarrDispatcher');
-var RightPanelActionTypes = require('../constants/JarrConstants').RightPanelActionTypes;
-var MenuActionTypes = require('../constants/JarrConstants').MenuActionTypes;
+var ActionTypes = require('../constants/JarrConstants');
var EventEmitter = require('events').EventEmitter;
var CHANGE_EVENT = 'change_middle_panel';
var assign = require('object-assign');
bgstack15