Skip to content

Commit

Permalink
frontend: Flush complete redux state on logout
Browse files Browse the repository at this point in the history
Closes #246
  • Loading branch information
pschlan committed Sep 2, 2024
1 parent dfe8a75 commit 7668b9c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion frontend/src/redux/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export const ActionTypes = {
SET_TIMEZONES: 'SET_TIMEZONES',
SET_USER_PROFILE: 'SET_USER_PROFILE',
SET_UI_SETTING: 'SET_UI_SETTING',
SET_FOLDERS: 'SET_FOLDERS'
SET_FOLDERS: 'SET_FOLDERS',
LOGOUT: 'LOGOUT'
};
4 changes: 1 addition & 3 deletions frontend/src/redux/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ export function setAuthToken(token) {
}

export function endSession() {
//! @todo Flush complete state!
return {
type: ActionTypes.SET_AUTH_SESSION,
session: null
type: ActionTypes.LOGOUT
}
}

Expand Down
13 changes: 11 additions & 2 deletions frontend/src/redux/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import timezones from './timezones';
import userProfile from './userProfile';
import ui from './ui';
import folders from './folders';
import { ActionTypes } from '../actionTypes';

export default combineReducers({
const appReducer = combineReducers({
auth,
dashboard,
jobs,
Expand All @@ -17,4 +18,12 @@ export default combineReducers({
folders
});

//! @todo Logout: Flush state
const rootReducer = (state, action) => {
if (action.type === ActionTypes.LOGOUT) {
return appReducer(undefined, action);
} else {
return appReducer(state, action);
}
}

export default rootReducer;

0 comments on commit 7668b9c

Please sign in to comment.