Move settings visibility to global state

Fixes #95
This commit is contained in:
Thomas Nordquist
2019-04-10 19:53:10 +02:00
parent b6d6575543
commit dcff2ae336
9 changed files with 36 additions and 38 deletions

View File

@@ -17,26 +17,29 @@ export interface GlobalAction extends Action {
showUpdateDetails?: boolean
error?: string
notification?: string
settingsVisible: boolean
}
export interface GlobalState {
interface GlobalStateInterface {
showUpdateNotification?: boolean
showUpdateDetails: boolean
error?: string
notification?: string
launching: boolean
settingsVisible: boolean
}
const initialGlobalState = Record<GlobalState>({
export type GlobalState = Record<GlobalStateInterface>
const initialStateFactory = Record<GlobalStateInterface>({
showUpdateNotification: false,
showUpdateDetails: false,
error: undefined,
notification: undefined,
launching: true,
settingsVisible: false,
})
export const globalState: Reducer<Record<GlobalState>, GlobalAction> = (state = initialGlobalState(), action): Record<GlobalState> => {
export const globalState: Reducer<Record<GlobalStateInterface>, GlobalAction> = (state = initialStateFactory(), action): GlobalState => {
trackEvent(action.type)
console.log(action.type)
@@ -44,6 +47,9 @@ export const globalState: Reducer<Record<GlobalState>, GlobalAction> = (state =
case ActionTypes.showUpdateNotification:
return state.set('showUpdateNotification', action.showUpdateNotification)
case ActionTypes.toggleSettingsVisibility:
return state.set('settingsVisible', !state.get('settingsVisible'))
case ActionTypes.showError:
return state.set('error', action.error)