Clean store fields, move from state.ui to state.app those that make sense

This commit is contained in:
Franc Camps-Febrer
2018-12-06 13:16:40 +00:00
parent fe6922d8fb
commit 89a7290dbf
14 changed files with 90 additions and 119 deletions

View File

@@ -11,7 +11,10 @@ import {
RESET_ALLFILTERS,
TOGGLE_LANGUAGE,
TOGGLE_MAPVIEW,
TOGGLE_GUIDEDMODE,
TOGGLE_FETCHING_DOMAIN,
TOGGLE_FETCHING_EVENTS,
TOGGLE_INFOPOPUP,
TOGGLE_NOTIFICATIONS,
FETCH_ERROR,
} from '../actions';
@@ -113,12 +116,6 @@ function toggleMapView(appState, action) {
});
}
function toggleGuidedMode(appState, action) {
return Object.assign({}, appState, {
isModeGuided: !appState.isModeGuided
})
}
function fetchError(state, action) {
return {
...state,
@@ -127,6 +124,39 @@ function fetchError(state, action) {
}
}
function toggleFetchingDomain(appState, action) {
return Object.assign({}, appState, {
flags: Object.assign({}, appState.flags, {
isFetchingDomain: !appState.flags.isFetchingDomain
})
});
}
function toggleFetchingEvents(appState, action) {
return Object.assign({}, appState, {
flags: Object.assign({}, appState.flags, {
isFetchingEvents: !appState.flags.isFetchingEvents
})
});
}
function toggleInfoPopup(appState, action) {
return Object.assign({}, appState, {
flags: Object.assign({}, appState.flags, {
isInfopopup: !appState.flags.isInfopopup
})
});
}
function toggleNotifications(appState, action) {
return Object.assign({}, appState, {
flags: Object.assign({}, appState.flags, {
isNotification: !appState.flags.isNotification
})
});
}
function app(appState = initial.app, action) {
switch (action.type) {
@@ -146,10 +176,16 @@ function app(appState = initial.app, action) {
return toggleLanguage(appState, action);
case TOGGLE_MAPVIEW:
return toggleMapView(appState, action);
case TOGGLE_GUIDEDMODE:
return toggleGuidedMode(appState, action);
case FETCH_ERROR:
return fetchError(appState, action);
case TOGGLE_FETCHING_DOMAIN:
return toggleFetchingDomain(appState, action);
case TOGGLE_FETCHING_EVENTS:
return toggleFetchingEvents(appState, action);
case TOGGLE_INFOPOPUP:
return toggleInfoPopup(appState, action);
case TOGGLE_NOTIFICATIONS:
return toggleNotifications(appState, action);
default:
return appState;
}

View File

@@ -1,55 +1,9 @@
import initial from '../store/initial.js';
import {
TOGGLE_FETCHING_DOMAIN,
TOGGLE_FETCHING_SOURCES,
TOGGLE_VIEW,
TOGGLE_TIMELINE,
TOGGLE_INFOPOPUP,
TOGGLE_NOTIFICATIONS
} from '../actions'
function toggleFetchingDomain(uiState, action) {
return {
...uiState,
flags: {
...uiState.flags,
isFetchingDomain: !uiState.flags.isFetchingDomain
}
}
}
function toggleFetchingSources(uiState, action) {
return {
...uiState,
flags: {
...uiState.flags,
isFetchingSources: !uiState.flags.isFetchingSources
}
}
}
function toggleInfoPopup(uiState, action) {
return {
...uiState,
flags: {
...uiState.flags,
isInfopopup: !uiState.flags.isInfopopup
}
}
}
import {} from '../actions'
function ui(uiState = initial.ui, action) {
switch (action.type) {
case TOGGLE_FETCHING_DOMAIN:
return toggleFetchingDomain(uiState, action)
case TOGGLE_FETCHING_SOURCES:
return toggleFetchingSources(uiState, action)
case TOGGLE_INFOPOPUP:
return toggleInfoPopup(uiState, action)
default:
return uiState
}
return uiState;
}
export default ui;