aboutsummaryrefslogtreecommitdiff
path: root/src/web/js/actions/MiddlePanelActions.js
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2020-02-26 11:27:31 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2020-02-26 11:27:31 +0100
commit62b3afeeedfe054345f86093e2d243e956c1e3c9 (patch)
treebbd58f5c8c07f5d87b1c1cca73fa1d5af6178f48 /src/web/js/actions/MiddlePanelActions.js
parentUpdated Python dependencies. (diff)
downloadnewspipe-62b3afeeedfe054345f86093e2d243e956c1e3c9.tar.gz
newspipe-62b3afeeedfe054345f86093e2d243e956c1e3c9.tar.bz2
newspipe-62b3afeeedfe054345f86093e2d243e956c1e3c9.zip
The project is now using Poetry.
Diffstat (limited to 'src/web/js/actions/MiddlePanelActions.js')
-rw-r--r--src/web/js/actions/MiddlePanelActions.js132
1 files changed, 0 insertions, 132 deletions
diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js
deleted file mode 100644
index 700814d4..00000000
--- a/src/web/js/actions/MiddlePanelActions.js
+++ /dev/null
@@ -1,132 +0,0 @@
-var JarrDispatcher = require('../dispatcher/JarrDispatcher');
-var ActionTypes = require('../constants/JarrConstants');
-var jquery = require('jquery');
-var MiddlePanelStore = require('../stores/MiddlePanelStore');
-
-var _last_fetched_with = {};
-
-var reloadAndDispatch = function(dispath_payload) {
- var filters = MiddlePanelStore.getRequestFilter(
- dispath_payload.display_search);
- MiddlePanelStore.filter_whitelist.map(function(key) {
- if(key in dispath_payload) {
- filters[key] = dispath_payload[key];
- }
- if(filters[key] == null) {
- delete filters[key];
- }
- });
- if('display_search' in filters) {
- delete filters['display_search'];
- }
- 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();
- });
-}
-
-
-var MiddlePanelActions = {
- reload: function() {
- reloadAndDispatch({
- type: ActionTypes.RELOAD_MIDDLE_PANEL,
- });
- },
- search: function(search) {
- reloadAndDispatch({
- type: ActionTypes.RELOAD_MIDDLE_PANEL,
- display_search: true,
- query: search.query,
- search_title: search.title,
- search_content: search.content,
- });
- },
- search_off: function() {
- reloadAndDispatch({
- type: ActionTypes.RELOAD_MIDDLE_PANEL,
- display_search: false,
- });
- },
- removeParentFilter: function() {
- reloadAndDispatch({
- type: ActionTypes.PARENT_FILTER,
- filter_type: null,
- filter_id: null,
- });
- },
- setCategoryFilter: function(category_id) {
- reloadAndDispatch({
- type: ActionTypes.PARENT_FILTER,
- filter_type: 'category_id',
- filter_id: category_id,
- });
- },
- setFeedFilter: function(feed_id) {
- reloadAndDispatch({
- type: ActionTypes.PARENT_FILTER,
- filter_type: 'feed_id',
- filter_id: feed_id,
- });
- },
- setFilter: function(filter) {
- reloadAndDispatch({
- type: ActionTypes.MIDDLE_PANEL_FILTER,
- filter: filter,
- });
- },
- changeRead: function(category_id, feed_id, 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 () {
- JarrDispatcher.dispatch({
- type: ActionTypes.CHANGE_ATTR,
- attribute: 'read',
- value_bool: new_value,
- value_num: new_value ? -1 : 1,
- articles: [{article_id: article_id,
- category_id: category_id,
- feed_id: feed_id}],
- });
- },
- });
- },
- changeLike: function(category_id, feed_id, 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 () {
- JarrDispatcher.dispatch({
- type: ActionTypes.CHANGE_ATTR,
- attribute: 'liked',
- value_bool: new_value,
- value_num: new_value ? -1 : 1,
- articles: [{article_id: article_id,
- category_id: category_id,
- feed_id: feed_id}],
- });
- },
- });
- },
- 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.MARK_ALL_AS_READ,
- articles: payload.articles,
- });
- },
- });
- },
-};
-
-module.exports = MiddlePanelActions;
bgstack15