mirror of
https://github.com/usatiuk/writer.git
synced 2025-10-29 00:17:48 +01:00
reset all state on logout
This commit is contained in:
@@ -40,4 +40,4 @@
|
||||
"autoprefixer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Reducer } from "react";
|
||||
import { IDocumentJSON } from "~../../src/entity/Document";
|
||||
import { UserAction, UserTypes } from "~redux/user/actions";
|
||||
|
||||
import { DocsAction, DocsTypes } from "./actions";
|
||||
|
||||
@@ -25,7 +26,7 @@ const defaultDocsState: IDocsState = {
|
||||
|
||||
export const docsReducer: Reducer<IDocsState, DocsAction> = (
|
||||
state: IDocsState = defaultDocsState,
|
||||
action: DocsAction,
|
||||
action: DocsAction | UserAction,
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case DocsTypes.DOCS_SHOW_SPINNER:
|
||||
@@ -71,6 +72,8 @@ export const docsReducer: Reducer<IDocsState, DocsAction> = (
|
||||
}
|
||||
case DocsTypes.DOCS_FETCH_FAIL:
|
||||
return { ...defaultDocsState, ...action.payload };
|
||||
case UserTypes.USER_LOGOUT:
|
||||
return defaultDocsState;
|
||||
default:
|
||||
return state;
|
||||
break;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Reducer } from "react";
|
||||
import { UserAction, UserTypes } from "~redux/user/actions";
|
||||
|
||||
import { LocalSettingsAction, LocalSettingsTypes } from "./actions";
|
||||
|
||||
@@ -15,12 +16,14 @@ export const localSettingsReducer: Reducer<
|
||||
LocalSettingsAction
|
||||
> = (
|
||||
state: ILocalSettingsState = defaultLocalSettingsState,
|
||||
action: LocalSettingsAction,
|
||||
action: LocalSettingsAction | UserAction,
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case LocalSettingsTypes.TOGGLE_DARK_MODE:
|
||||
const { darkMode } = state;
|
||||
return { ...state, darkMode: !darkMode };
|
||||
case UserTypes.USER_LOGOUT:
|
||||
return defaultLocalSettingsState;
|
||||
default:
|
||||
return state;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user