From acc8edf360776a7b8f9e0e364fba653dd66ab775 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Mon, 17 Apr 2017 11:24:18 -0700 Subject: [PATCH] Update syntax + var names + patterns to convention --- ui/src/shared/reducers/app.js | 16 +++++++++------- ui/src/shared/reducers/auth.js | 2 +- ui/src/shared/reducers/errors.js | 4 ++-- ui/src/shared/reducers/notifications.js | 4 +++- ui/src/shared/reducers/sources.js | 8 +++++++- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ui/src/shared/reducers/app.js b/ui/src/shared/reducers/app.js index 6312d3a0c..366ac49ec 100644 --- a/ui/src/shared/reducers/app.js +++ b/ui/src/shared/reducers/app.js @@ -12,11 +12,11 @@ const initialState = { } const { - ephemeral: initialEphemeralState, - persisted: initialPersistedState, + ephemeral: initialAppEphemeralState, + persisted: initialAppPersistedState, } = initialState -const ephemeralReducer = (state = initialEphemeralState, action) => { +const appEphemeralReducer = (state = initialAppEphemeralState, action) => { switch (action.type) { case 'ENABLE_PRESENTATION_MODE': { return { @@ -37,7 +37,7 @@ const ephemeralReducer = (state = initialEphemeralState, action) => { } } -const persistedReducer = (state = initialPersistedState, action) => { +const appPersistedReducer = (state = initialAppPersistedState, action) => { switch (action.type) { case 'SET_AUTOREFRESH': { return { @@ -51,7 +51,9 @@ const persistedReducer = (state = initialPersistedState, action) => { } } -export default combineReducers({ - ephemeral: ephemeralReducer, - persisted: persistedReducer, +const appReducer = combineReducers({ + ephemeral: appEphemeralReducer, + persisted: appPersistedReducer, }) + +export default appReducer diff --git a/ui/src/shared/reducers/auth.js b/ui/src/shared/reducers/auth.js index 351528121..6accd8cce 100644 --- a/ui/src/shared/reducers/auth.js +++ b/ui/src/shared/reducers/auth.js @@ -31,7 +31,7 @@ const authReducer = (state = initialState, action) => { return {...state, me, isMeLoading: false} } case 'LOGOUT': { - return {} + return {...initialState} } } diff --git a/ui/src/shared/reducers/errors.js b/ui/src/shared/reducers/errors.js index b69828de9..df58b99e8 100644 --- a/ui/src/shared/reducers/errors.js +++ b/ui/src/shared/reducers/errors.js @@ -4,7 +4,7 @@ const getInitialState = () => ({ const initialState = getInitialState() -const errors = (state = initialState, action) => { +const errorsReducer = (state = initialState, action) => { switch (action.type) { case 'ERROR_THROWN': { return {...action.error} @@ -14,4 +14,4 @@ const errors = (state = initialState, action) => { return state } -export default errors +export default errorsReducer diff --git a/ui/src/shared/reducers/notifications.js b/ui/src/shared/reducers/notifications.js index e0307aa1a..c4275fcd8 100644 --- a/ui/src/shared/reducers/notifications.js +++ b/ui/src/shared/reducers/notifications.js @@ -5,7 +5,7 @@ function getInitialState() { } const initialState = getInitialState() -export default function notifications(state = initialState, action) { +const notificationsReducer = (state = initialState, action) => { switch (action.type) { case 'NOTIFICATION_RECEIVED': { const {type, message} = action.payload @@ -22,3 +22,5 @@ export default function notifications(state = initialState, action) { return state } + +export default notificationsReducer diff --git a/ui/src/shared/reducers/sources.js b/ui/src/shared/reducers/sources.js index 67c87bfca..cfef11c40 100644 --- a/ui/src/shared/reducers/sources.js +++ b/ui/src/shared/reducers/sources.js @@ -1,4 +1,8 @@ -export default function sources(state = [], action) { +const getInitialState = () => [] + +const initialState = getInitialState() + +const sourcesReducer = (state = initialState, action) => { switch (action.type) { case 'LOAD_SOURCES': { return action.payload.sources @@ -25,3 +29,5 @@ export default function sources(state = [], action) { return state } + +export default sourcesReducer