diff --git a/lib/reducers/enabled-apps-reducer.js b/lib/reducers/enabled-apps-reducer.js --- a/lib/reducers/enabled-apps-reducer.js +++ b/lib/reducers/enabled-apps-reducer.js @@ -11,6 +11,7 @@ defaultWebEnabledApps, } from '../types/enabled-apps.js'; import type { BaseAction } from '../types/redux-types.js'; +import { usingCommServicesAccessToken } from '../utils/services-utils.js'; export const enableAppActionType = 'ENABLE_APP'; export const disableAppActionType = 'DISABLE_APP'; @@ -26,13 +27,16 @@ action.payload === 'calendar' ) { return { ...state, calendar: false }; + } else if (action.type === logOutActionTypes.success) { + return process.env.BROWSER ? defaultWebEnabledApps : defaultEnabledApps; } else if ( - action.type === logOutActionTypes.success || action.type === deleteKeyserverAccountActionTypes.success || (action.type === setNewSessionActionType && action.payload.sessionChange.cookieInvalidated) ) { - return process.env.BROWSER ? defaultWebEnabledApps : defaultEnabledApps; + if (!usingCommServicesAccessToken) { + return process.env.BROWSER ? defaultWebEnabledApps : defaultEnabledApps; + } } return state; } diff --git a/lib/reducers/services-access-token-reducer.js b/lib/reducers/services-access-token-reducer.js --- a/lib/reducers/services-access-token-reducer.js +++ b/lib/reducers/services-access-token-reducer.js @@ -7,6 +7,7 @@ } from '../actions/user-actions.js'; import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js'; import type { BaseAction } from '../types/redux-types.js'; +import { usingCommServicesAccessToken } from '../utils/services-utils.js'; export default function reduceServicesAccessToken( state: ?string, @@ -22,10 +23,13 @@ return null; } else if ( action.type === logOutActionTypes.started || - action.type === logOutActionTypes.success || - action.type === deleteKeyserverAccountActionTypes.success + action.type === logOutActionTypes.success ) { return null; + } else if (action.type === deleteKeyserverAccountActionTypes.success) { + if (!usingCommServicesAccessToken) { + return null; + } } return state; } diff --git a/lib/reducers/theme-reducer.js b/lib/reducers/theme-reducer.js --- a/lib/reducers/theme-reducer.js +++ b/lib/reducers/theme-reducer.js @@ -15,6 +15,7 @@ defaultGlobalThemeInfo, type GlobalThemeInfo, } from '../types/theme-types.js'; +import { usingCommServicesAccessToken } from '../utils/services-utils.js'; export default function reduceGlobalThemeInfo( state: GlobalThemeInfo, @@ -35,10 +36,13 @@ return defaultGlobalThemeInfo; } else if ( action.type === logOutActionTypes.started || - action.type === logOutActionTypes.success || - action.type === deleteKeyserverAccountActionTypes.success + action.type === logOutActionTypes.success ) { return defaultGlobalThemeInfo; + } else if (action.type === deleteKeyserverAccountActionTypes.success) { + if (!usingCommServicesAccessToken) { + return defaultGlobalThemeInfo; + } } else if (action.type === updateThemeInfoActionType) { return { ...state, diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js --- a/lib/reducers/user-reducer.js +++ b/lib/reducers/user-reducer.js @@ -57,12 +57,18 @@ action.type === logInActionTypes.success || action.type === siweAuthActionTypes.success || action.type === keyserverRegisterActionTypes.success || - action.type === logOutActionTypes.success || - action.type === deleteKeyserverAccountActionTypes.success + action.type === logOutActionTypes.success ) { if (!_isEqual(action.payload.currentUserInfo)(state)) { return action.payload.currentUserInfo; } + } else if (action.type === deleteKeyserverAccountActionTypes.success) { + if ( + !usingCommServicesAccessToken && + !_isEqual(action.payload.currentUserInfo)(state) + ) { + return action.payload.currentUserInfo; + } } else if ( action.type === setNewSessionActionType && action.payload.sessionChange.currentUserInfo diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -27,6 +27,7 @@ import { rehydrateActionType } from 'lib/types/redux-types.js'; import type { SetSessionPayload } from 'lib/types/session-types.js'; import { reduxLoggerMiddleware } from 'lib/utils/action-logger.js'; +import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js'; import { ashoatKeyserverID } from 'lib/utils/validation-utils.js'; import { @@ -193,8 +194,7 @@ }; } else if ( action.type === logOutActionTypes.started || - action.type === logOutActionTypes.success || - action.type === deleteKeyserverAccountActionTypes.success + action.type === logOutActionTypes.success ) { state = { ...state, @@ -202,6 +202,15 @@ isBackupEnabled: false, }, }; + } else if (action.type === deleteKeyserverAccountActionTypes.success) { + if (!usingCommServicesAccessToken) { + state = { + ...state, + localSettings: { + isBackupEnabled: false, + }, + }; + } } if (action.type === setNewSessionActionType) { diff --git a/web/redux/crypto-store-reducer.js b/web/redux/crypto-store-reducer.js --- a/web/redux/crypto-store-reducer.js +++ b/web/redux/crypto-store-reducer.js @@ -6,6 +6,7 @@ } from 'lib/actions/user-actions.js'; import { setNewSessionActionType } from 'lib/keyserver-conn/keyserver-conn-types.js'; import type { CryptoStore } from 'lib/types/crypto-types.js'; +import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js'; import type { Action } from './redux-setup.js'; @@ -14,13 +15,16 @@ function reduceCryptoStore(state: ?CryptoStore, action: Action): ?CryptoStore { if (action.type === setCryptoStore) { return action.payload; + } else if (action.type === logOutActionTypes.success) { + return null; } else if ( - action.type === logOutActionTypes.success || action.type === deleteKeyserverAccountActionTypes.success || (action.type === setNewSessionActionType && action.payload.sessionChange.cookieInvalidated) ) { - return null; + if (!usingCommServicesAccessToken) { + return null; + } } return state; }