aboutsummaryrefslogtreecommitdiff
path: root/src/web/js/actions
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/actions
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/actions')
-rw-r--r--src/web/js/actions/MenuActions.js11
-rw-r--r--src/web/js/actions/MiddlePanelActions.js57
2 files changed, 53 insertions, 15 deletions
diff --git a/src/web/js/actions/MenuActions.js b/src/web/js/actions/MenuActions.js
index c3cc95bc..1f1eea01 100644
--- a/src/web/js/actions/MenuActions.js
+++ b/src/web/js/actions/MenuActions.js
@@ -17,19 +17,20 @@ var MenuActions = {
},
setFilterAll: function() {
JarrDispatcher.dispatch({
- component: 'menu',
- type: MenuActionTypes.MENU_FILTER_ALL,
+ type: MenuActionTypes.MENU_FILTER,
+ filter: 'all',
});
},
setFilterUnread: function() {
JarrDispatcher.dispatch({
- component: 'menu',
- type: MenuActionTypes.MENU_FILTER_UNREAD,
+ type: MenuActionTypes.MENU_FILTER,
+ filter: 'unread',
});
},
setFilterError: function() {
JarrDispatcher.dispatch({
- type: MenuActionTypes.MENU_FILTER_ERROR,
+ type: MenuActionTypes.MENU_FILTER,
+ filter: 'error',
});
},
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;
bgstack15