aboutsummaryrefslogtreecommitdiff
path: root/src/web/js/actions/MiddlePanelActions.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/js/actions/MiddlePanelActions.js')
-rw-r--r--src/web/js/actions/MiddlePanelActions.js17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/web/js/actions/MiddlePanelActions.js b/src/web/js/actions/MiddlePanelActions.js
index e1ced2a2..ec76d2bc 100644
--- a/src/web/js/actions/MiddlePanelActions.js
+++ b/src/web/js/actions/MiddlePanelActions.js
@@ -21,14 +21,16 @@ 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();
- for (var key in filters) {
- if(dispath_payload[key] != null) {
+ key_whitelist.map(function(key) {
+ if(key in dispath_payload) {
filters[key] = dispath_payload[key];
}
- }
+ });
jquery.getJSON('/middle_panel', filters,
function(payload) {
dispath_payload.articles = payload.articles;
@@ -43,13 +45,8 @@ var reloadIfNecessaryAndDispatch = function(dispath_payload) {
var MiddlePanelActions = {
reload: function() {
- var filters = MiddlePanelStore.getRequestFilter();
- jquery.getJSON('/middle_panel', filters, function(payload) {
- _last_fetched_with = filters;
- JarrDispatcher.dispatch({
- type: ActionTypes.RELOAD_MIDDLE_PANEL,
- articles: payload.articles,
- });
+ reloadIfNecessaryAndDispatch({
+ type: ActionTypes.RELOAD_MIDDLE_PANEL,
});
},
search: function(search) {
bgstack15