aboutsummaryrefslogtreecommitdiff
path: root/src/web/js
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2016-02-02 21:55:57 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2016-02-02 21:55:57 +0100
commitded0971f5691ed2934e690c8d7bd480ed15402f7 (patch)
tree0695b1792674a6b12d9e165429554f524f00c8ef /src/web/js
parentordering categories in the feed form (diff)
downloadnewspipe-ded0971f5691ed2934e690c8d7bd480ed15402f7.tar.gz
newspipe-ded0971f5691ed2934e690c8d7bd480ed15402f7.tar.bz2
newspipe-ded0971f5691ed2934e690c8d7bd480ed15402f7.zip
updating unread count when fetching unread
Diffstat (limited to 'src/web/js')
-rw-r--r--src/web/js/actions/MiddlePanelActions.js1
-rw-r--r--src/web/js/components/RightPanel.react.js2
-rw-r--r--src/web/js/stores/MenuStore.js34
3 files changed, 30 insertions, 7 deletions
diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js
index 08510f29..f805b7b1 100644
--- a/src/web/js/actions/MiddlePanelActions.js
+++ b/src/web/js/actions/MiddlePanelActions.js
@@ -39,6 +39,7 @@ var reloadIfNecessaryAndDispatch = function(dispath_payload) {
jquery.getJSON('/middle_panel', filters,
function(payload) {
dispath_payload.articles = payload.articles;
+ dispath_payload.filters = filters;
JarrDispatcher.dispatch(dispath_payload);
_last_fetched_with = MiddlePanelStore.getRequestFilter();
});
diff --git a/src/web/js/components/RightPanel.react.js b/src/web/js/components/RightPanel.react.js
index 3b625689..1e66ce39 100644
--- a/src/web/js/components/RightPanel.react.js
+++ b/src/web/js/components/RightPanel.react.js
@@ -39,7 +39,7 @@ var PanelMixin = {
</ButtonGroup>);
}
return (<div id="right-panel-heading" className="panel-heading">
- <h4>{icon}<strong>Title:</strong> {this.getTitle()}</h4>
+ <h4>{icon}{this.getTitle()}</h4>
{btn_grp}
</div>);
},
diff --git a/src/web/js/stores/MenuStore.js b/src/web/js/stores/MenuStore.js
index d3c44355..36dee363 100644
--- a/src/web/js/stores/MenuStore.js
+++ b/src/web/js/stores/MenuStore.js
@@ -56,12 +56,34 @@ MenuStore.dispatchToken = JarrDispatcher.register(function(action) {
break;
case ActionTypes.PARENT_FILTER:
MenuStore.setActive(action.filter_type, action.filter_id);
- break;
- case ActionTypes.MENU_FILTER:
- MenuStore.setFilter(action.filter);
- break;
- case ActionTypes.MENU_FILTER:
- MenuStore.setFilter(action.filter);
+ if(action.filters && action.articles && !action.filters.query
+ && action.filters.filter == 'unread') {
+ var new_unread = {};
+ action.articles.map(function(article) {
+ if(!(article.feed_id in new_unread)) {
+ new_unread[article.feed_id] = 0;
+ }
+ if(!article.read) {
+ new_unread[article.feed_id] += 1;
+ }
+ });
+ var changed = false;
+ for(var feed_id in new_unread) {
+ var old_unread = MenuStore._datas.feeds[feed_id].unread;
+ if(old_unread == new_unread[feed_id]) {
+ continue;
+ }
+ changed = true;
+ MenuStore._datas.feeds[feed_id].unread = new_unread[feed_id];
+ var cat_id = MenuStore._datas.feeds[feed_id].category_id;
+ MenuStore._datas.categories[cat_id].unread -= old_unread;
+ MenuStore._datas.categories[cat_id].unread += new_unread[feed_id];
+ }
+ if(changed) {
+ MenuStore.emitChange();
+ }
+ }
+
break;
case ActionTypes.MENU_FILTER:
MenuStore.setFilter(action.filter);
bgstack15