mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-13 05:48:36 +03:00
Clean store fields, move from state.ui to state.app those that make sense
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user