aboutsummaryrefslogtreecommitdiff
path: root/src/web/js/actions
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2016-01-29 13:02:49 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2016-01-29 13:02:49 +0100
commit5eae4cb235abed7a6e8c6ab81226def9dddc0af2 (patch)
tree0b41f30356c4c557fb76ea798c718dd6ee629b56 /src/web/js/actions
parentwip right panel (diff)
downloadnewspipe-5eae4cb235abed7a6e8c6ab81226def9dddc0af2.tar.gz
newspipe-5eae4cb235abed7a6e8c6ab81226def9dddc0af2.tar.bz2
newspipe-5eae4cb235abed7a6e8c6ab81226def9dddc0af2.zip
correcting awful middle panel action handling
Diffstat (limited to 'src/web/js/actions')
-rw-r--r--src/web/js/actions/MiddlePanelActions.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js
index ec76d2bc..08510f29 100644
--- a/src/web/js/actions/MiddlePanelActions.js
+++ b/src/web/js/actions/MiddlePanelActions.js
@@ -21,16 +21,21 @@ var shouldFetch = function(filters) {
// }
// return false;
}
-var key_whitelist = ['filter_id', 'filter_type',
- 'query', 'search_title', 'search_content'];
var reloadIfNecessaryAndDispatch = function(dispath_payload) {
if(shouldFetch(dispath_payload)) {
- var filters = MiddlePanelStore.getRequestFilter();
- key_whitelist.map(function(key) {
+ 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;
@@ -50,15 +55,19 @@ var MiddlePanelActions = {
});
},
search: function(search) {
- MiddlePanelStore._datas.display_search = true;
- MiddlePanelStore._datas.query = search.query;
- MiddlePanelStore._datas.search_content = search.content;
- MiddlePanelStore._datas.search_content = search.content;
- this.reload();
+ reloadIfNecessaryAndDispatch({
+ type: ActionTypes.RELOAD_MIDDLE_PANEL,
+ display_search: true,
+ query: search.query,
+ search_title: search.title,
+ search_content: search.content,
+ });
},
search_off: function() {
- MiddlePanelStore._datas.display_search = false;
- this.reload();
+ reloadIfNecessaryAndDispatch({
+ type: ActionTypes.RELOAD_MIDDLE_PANEL,
+ display_search: false,
+ });
},
removeParentFilter: function() {
reloadIfNecessaryAndDispatch({
bgstack15