diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2016-01-23 12:47:18 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2016-01-26 23:47:10 +0100 |
commit | 3644d4ef190d2d509c64fdf5c29382cb8a41e235 (patch) | |
tree | f95124c888be848294daa4015dda36bf9c73c51d /src/web/js/actions/MiddlePanelActions.js | |
parent | meh, kinda works, sleep now (diff) | |
download | newspipe-3644d4ef190d2d509c64fdf5c29382cb8a41e235.tar.gz newspipe-3644d4ef190d2d509c64fdf5c29382cb8a41e235.tar.bz2 newspipe-3644d4ef190d2d509c64fdf5c29382cb8a41e235.zip |
doing some design
wip toogle read / like
Diffstat (limited to 'src/web/js/actions/MiddlePanelActions.js')
-rw-r--r-- | src/web/js/actions/MiddlePanelActions.js | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js index 159ba91b..7a944ecd 100644 --- a/src/web/js/actions/MiddlePanelActions.js +++ b/src/web/js/actions/MiddlePanelActions.js @@ -28,10 +28,11 @@ var reloadIfNecessaryAndDispatch = function(dispath_payload) { filters[key] = dispath_payload[key]; } } - jquery.getJSON('/middle_panel', dispath_payload, function(payload) { - dispath_payload.articles = payload.articles; - JarrDispatcher.dispatch(dispath_payload); - _last_fetched_with = MiddlePanelStore.getRequestFilter(); + jquery.getJSON('/middle_panel', dispath_payload, + function(payload) { + dispath_payload.articles = payload.articles; + JarrDispatcher.dispatch(dispath_payload); + _last_fetched_with = MiddlePanelStore.getRequestFilter(); }); } else { JarrDispatcher.dispatch(dispath_payload); @@ -50,24 +51,24 @@ var MiddlePanelActions = { }); }); }, - removeParentFilter: function(filter_type, filter_id) { + removeParentFilter: function() { reloadIfNecessaryAndDispatch({ - type: MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER, + type: MiddlePanelActionTypes.PARENT_FILTER, filter_type: null, filter_id: null, }); }, setCategoryFilter: function(category_id) { reloadIfNecessaryAndDispatch({ - type: MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER, - filter_type: 'category', + type: MiddlePanelActionTypes.PARENT_FILTER, + filter_type: 'category_id', filter_id: category_id, }); }, setFeedFilter: function(feed_id) { reloadIfNecessaryAndDispatch({ - type: MiddlePanelActionTypes.MIDDLE_PANEL_PARENT_FILTER, - filter_type: 'feed', + type: MiddlePanelActionTypes.PARENT_FILTER, + filter_type: 'feed_id', filter_id: feed_id, }); }, @@ -89,6 +90,42 @@ var MiddlePanelActions = { filter: 'liked', }); }, + changeRead: function(article_id, new_value){ + jquery.ajax({type: 'PUT', + contentType: 'application/json', + data: JSON.stringify({readed: new_value}), + url: "api/v2.0/article/" + article_id, + success: function (result) { + JarrDispatcher.dispatch({ + type: MiddlePanelActionTypes.CHANGE_ATTR, + article_id: article_id, + attribute: 'read', + value: new_value, + }); + }, + error: function(XMLHttpRequest, textStatus, errorThrown){ + console.log(XMLHttpRequest.responseText); + }, + }); + }, + changeLike: function(article_id, new_value){ + jquery.ajax({type: 'PUT', + contentType: 'application/json', + data: JSON.stringify({like: new_value}), + url: "api/v2.0/article/" + article_id, + success: function (result) { + JarrDispatcher.dispatch({ + type: MiddlePanelActionTypes.CHANGE_ATTR, + article_id: article_id, + attribute: 'liked', + value: new_value, + }); + }, + error: function(XMLHttpRequest, textStatus, errorThrown){ + console.log(XMLHttpRequest.responseText); + }, + }); + }, }; module.exports = MiddlePanelActions; |