aboutsummaryrefslogtreecommitdiff
path: root/src/web/js/stores
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2016-01-23 12:47:18 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2016-01-26 23:47:10 +0100
commit3644d4ef190d2d509c64fdf5c29382cb8a41e235 (patch)
treef95124c888be848294daa4015dda36bf9c73c51d /src/web/js/stores
parentmeh, kinda works, sleep now (diff)
downloadnewspipe-3644d4ef190d2d509c64fdf5c29382cb8a41e235.tar.gz
newspipe-3644d4ef190d2d509c64fdf5c29382cb8a41e235.tar.bz2
newspipe-3644d4ef190d2d509c64fdf5c29382cb8a41e235.zip
doing some design
wip toogle read / like
Diffstat (limited to 'src/web/js/stores')
-rw-r--r--src/web/js/stores/MenuStore.js24
-rw-r--r--src/web/js/stores/MiddlePanelStore.js19
2 files changed, 34 insertions, 9 deletions
diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js
index 016b33f2..6809d8b0 100644
--- a/src/web/js/stores/MenuStore.js
+++ b/src/web/js/stores/MenuStore.js
@@ -6,7 +6,7 @@ var assign = require('object-assign');
var MenuStore = assign({}, EventEmitter.prototype, {
- _datas: {filter: 'all', categories: [],
+ _datas: {filter: 'all', categories: [], active_type: null, active_id: null,
all_unread_count: 0, feed_in_error: false},
getAll: function() {
return this._datas;
@@ -17,6 +17,13 @@ var MenuStore = assign({}, EventEmitter.prototype, {
this.emitChange();
}
},
+ setActive: function(type, value) {
+ if(this._datas.active_id != value || this._datas.active_type != type) {
+ this._datas.active_type = type;
+ this._datas.active_id = value;
+ this.emitChange();
+ }
+ },
readFeedArticle: function(feed_id) {
// TODO
},
@@ -40,14 +47,17 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) {
MenuStore._datas['all_unread_count'] = action.all_unread_count;
MenuStore.emitChange();
break;
- case MenuActionTypes.MENU_FILTER_ALL:
- MenuStore.setFilter('all');
+ case MenuActionTypes.PARENT_FILTER:
+ MenuStore.setActive(action.filter_type, action.filter_id);
+ break;
+ case MenuActionTypes.MENU_FILTER:
+ MenuStore.setFilter(action.filter);
break;
- case MenuActionTypes.MENU_FILTER_UNREAD:
- MenuStore.setFilter('unread');
+ case MenuActionTypes.MENU_FILTER:
+ MenuStore.setFilter(action.filter);
break;
- case MenuActionTypes.MENU_FILTER_ERROR:
- MenuStore.setFilter('error');
+ case MenuActionTypes.MENU_FILTER:
+ MenuStore.setFilter(action.filter);
break;
default:
diff --git a/src/web/js/stores/MiddlePanelStore.js b/src/web/js/stores/MiddlePanelStore.js
index 80ac8198..201bebd1 100644
--- a/src/web/js/stores/MiddlePanelStore.js
+++ b/src/web/js/stores/MiddlePanelStore.js
@@ -1,5 +1,6 @@
var JarrDispatcher = require('../dispatcher/JarrDispatcher');
var MiddlePanelActionTypes = require('../constants/JarrConstants').MiddlePanelActionTypes;
+var MenuActionTypes = require('../constants/JarrConstants').MenuActionTypes;
var EventEmitter = require('events').EventEmitter;
var CHANGE_EVENT = 'change_middle_panel';
var assign = require('object-assign');
@@ -21,7 +22,7 @@ var MiddlePanelStore = assign({}, EventEmitter.prototype, {
var id = null;
var filter = this._datas.filter;
if (this._datas.filter_type) {
- key = this._datas.filter_type + '_id';
+ key = this._datas.filter_type;
id = this._datas.filter_id;
}
return this._datas.articles.filter(function(article) {
@@ -72,7 +73,7 @@ MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) {
MiddlePanelStore.setArticles(action.articles);
MiddlePanelStore.emitChange();
break;
- case MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER:
+ case MiddlePanelActionTypes.PARENT_FILTER:
changed = MiddlePanelStore.setParentFilter(action.filter_type,
action.filter_id);
changed = MiddlePanelStore.setArticles(action.articles) || changed;
@@ -83,6 +84,20 @@ MiddlePanelStore.dispatchToken = JarrDispatcher.register(function(action) {
changed = MiddlePanelStore.setArticles(action.articles) || changed;
if(changed) {MiddlePanelStore.emitChange();}
break;
+ case MiddlePanelActionTypes.CHANGE_ATTR:
+ var id = action.article_id;
+ var attr = action.attribute;
+ var val = action.value;
+ for (var i in MiddlePanelStore._datas.articles) {
+ if(MiddlePanelStore._datas.articles[i].article_id == id) {
+ if (MiddlePanelStore._datas.articles[i][attr] != val) {
+ MiddlePanelStore._datas.articles[i][attr] = val;
+ MiddlePanelStore.emitChange();
+ }
+ break;
+ }
+ }
+ break;
default:
// pass
}
bgstack15