diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 23:23:42 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-27 00:34:34 +0100 |
commit | f3578d10239ffa716450c0089bcbc8d2826f59fd (patch) | |
tree | dd5a35e6ac3b953bd00f635c0db106e5081570d5 /src/web/js/actions | |
parent | optim on filter, not rerendering (diff) | |
download | newspipe-f3578d10239ffa716450c0089bcbc8d2826f59fd.tar.gz newspipe-f3578d10239ffa716450c0089bcbc8d2826f59fd.tar.bz2 newspipe-f3578d10239ffa716450c0089bcbc8d2826f59fd.zip |
mark all as read button
Diffstat (limited to 'src/web/js/actions')
-rw-r--r-- | src/web/js/actions/MiddlePanelActions.js | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js index 47a9958c..ab54217e 100644 --- a/src/web/js/actions/MiddlePanelActions.js +++ b/src/web/js/actions/MiddlePanelActions.js @@ -43,7 +43,7 @@ var reloadIfNecessaryAndDispatch = function(dispath_payload) { var MiddlePanelActions = { reload: function() { - filters = MiddlePanelStore.getRequestFilter(); + var filters = MiddlePanelStore.getRequestFilter(); jquery.getJSON('/middle_panel', filters, function(payload) { _last_fetched_with = filters; JarrDispatcher.dispatch({ @@ -84,19 +84,17 @@ var MiddlePanelActions = { contentType: 'application/json', data: JSON.stringify({readed: new_value}), url: "api/v2.0/article/" + article_id, - success: function (result) { + success: function () { JarrDispatcher.dispatch({ type: ActionTypes.CHANGE_ATTR, - article_id: article_id, - category_id: category_id, - feed_id: feed_id, attribute: 'read', - value: new_value, + value_bool: new_value, + value_num: new_value ? -1 : 1, + articles: [{article_id: article_id, + category_id: category_id, + feed_id: feed_id}], }); }, - error: function(XMLHttpRequest, textStatus, errorThrown){ - console.log(XMLHttpRequest.responseText); - }, }); }, changeLike: function(category_id, feed_id, article_id, new_value){ @@ -104,18 +102,33 @@ var MiddlePanelActions = { contentType: 'application/json', data: JSON.stringify({like: new_value}), url: "api/v2.0/article/" + article_id, - success: function (result) { + success: function () { JarrDispatcher.dispatch({ type: ActionTypes.CHANGE_ATTR, - article_id: article_id, - category_id: category_id, - feed_id: feed_id, attribute: 'liked', - value: new_value, + value_bool: new_value, + value_num: new_value ? -1 : 1, + articles: [{article_id: article_id, + category_id: category_id, + feed_id: feed_id}], }); }, - error: function(XMLHttpRequest, textStatus, errorThrown){ - console.log(XMLHttpRequest.responseText); + }); + }, + markAllAsRead: function() { + var filters = MiddlePanelStore.getRequestFilter(); + jquery.ajax({type: 'PUT', + contentType: 'application/json', + data: JSON.stringify(filters), + url: "/mark_all_as_read", + success: function (payload) { + JarrDispatcher.dispatch({ + type: ActionTypes.CHANGE_ATTR, + attribute: 'read', + value_num: -1, + value_bool: true, + articles: payload.articles, + }); }, }); }, |