Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33241064
D11533.1768569919.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D11533.1768569919.diff
View Options
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
@@ -13,8 +13,6 @@
logInActionTypes,
keyserverAuthActionTypes,
deleteKeyserverAccountActionTypes,
- identityRegisterActionTypes,
- identityLogInActionTypes,
} from 'lib/actions/user-actions.js';
import { setNewSessionActionType } from 'lib/keyserver-conn/keyserver-conn-types.js';
import type { ThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
@@ -22,6 +20,7 @@
import { queueDBOps } from 'lib/reducers/db-ops-reducer.js';
import { reduceLoadingStatuses } from 'lib/reducers/loading-reducer.js';
import baseReducer from 'lib/reducers/master-reducer.js';
+import { reduceCurrentUserInfo } from 'lib/reducers/user-reducer.js';
import {
invalidSessionDowngrade,
invalidSessionRecovery,
@@ -49,8 +48,8 @@
import { remoteReduxDevServerConfig } from './dev-tools.js';
import { persistConfig, setPersistor } from './persist.js';
import { onStateDifference } from './redux-debug-utils.js';
-import { nonUserSpecificFieldsNative } from './state-types.js';
import type { AppState } from './state-types.js';
+import { nonUserSpecificFieldsNative } from './state-types.js';
import { getGlobalNavContext } from '../navigation/icky-global.js';
import { activeMessageListSelector } from '../navigation/nav-selectors.js';
import reactotron from '../reactotron.js';
@@ -198,20 +197,6 @@
return state;
}
- if (
- action.type === logOutActionTypes.success ||
- action.type === deleteAccountActionTypes.success ||
- action.type === identityRegisterActionTypes.success ||
- (action.type === identityLogInActionTypes.success &&
- action.payload.userID !== action.payload.preRequestUserState?.id)
- ) {
- state = resetUserSpecificState(
- state,
- defaultState,
- nonUserSpecificFieldsNative,
- );
- }
-
if (action.type === updateDimensionsActiveType) {
return {
...state,
@@ -275,6 +260,25 @@
}
}
+ // We're reducing current user info twice. Once here - from the previous
+ // state, and once in baseReducer. This approach protects us against possible
+ // bugs in currentUserInfo reducer. BaseReducer acts on cleared
+ // currentUserInfo so there's no risk of keeping the old info with a new ID.
+ const newCurrentUserInfo = reduceCurrentUserInfo(
+ state.currentUserInfo,
+ action,
+ );
+ if (
+ !state.currentUserInfo?.anonymous &&
+ newCurrentUserInfo?.id !== state.currentUserInfo?.id
+ ) {
+ state = resetUserSpecificState(
+ state,
+ defaultState,
+ nonUserSpecificFieldsNative,
+ );
+ }
+
const baseReducerResult = baseReducer(
state,
(action: BaseAction),
diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js
--- a/web/redux/redux-setup.js
+++ b/web/redux/redux-setup.js
@@ -7,8 +7,6 @@
logOutActionTypes,
deleteKeyserverAccountActionTypes,
deleteAccountActionTypes,
- identityRegisterActionTypes,
- identityLogInActionTypes,
keyserverAuthActionTypes,
} from 'lib/actions/user-actions.js';
import { setNewSessionActionType } from 'lib/keyserver-conn/keyserver-conn-types.js';
@@ -23,6 +21,7 @@
import { queueDBOps } from 'lib/reducers/db-ops-reducer.js';
import { reduceLoadingStatuses } from 'lib/reducers/loading-reducer.js';
import baseReducer from 'lib/reducers/master-reducer.js';
+import { reduceCurrentUserInfo } from 'lib/reducers/user-reducer.js';
import { mostRecentlyReadThreadSelector } from 'lib/selectors/thread-selectors.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
import {
@@ -331,21 +330,26 @@
};
}
- if (
- action.type === logOutActionTypes.success ||
- action.type === deleteAccountActionTypes.success ||
- action.type === identityRegisterActionTypes.success ||
- (action.type === identityLogInActionTypes.success &&
- action.payload.userID !== action.payload.preRequestUserState?.id)
- ) {
- state = resetUserSpecificState(
- state,
- defaultWebState,
- nonUserSpecificFieldsWeb,
+ if (action.type !== updateNavInfoActionType) {
+ // We're reducing current user info twice. Once here - from the previous
+ // state, and once in baseReducer. This approach protects us against
+ // possible bugs in currentUserInfo reducer. BaseReducer acts on cleared
+ // currentUserInfo so there's no risk of keeping the old info with a new ID.
+ const newCurrentUserInfo = reduceCurrentUserInfo(
+ state.currentUserInfo,
+ action,
);
- }
+ if (
+ !state.currentUserInfo?.anonymous &&
+ newCurrentUserInfo?.id !== state.currentUserInfo?.id
+ ) {
+ state = resetUserSpecificState(
+ state,
+ defaultWebState,
+ nonUserSpecificFieldsWeb,
+ );
+ }
- if (action.type !== updateNavInfoActionType) {
const baseReducerResult = baseReducer(state, action, onStateDifference);
state = baseReducerResult.state;
storeOperations = {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 16, 1:25 PM (6 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5944493
Default Alt Text
D11533.1768569919.diff (4 KB)
Attached To
Mode
D11533: [web][native] Reset the state iff current user ID changes
Attached
Detach File
Event Timeline
Log In to Comment