Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32930451
D10157.1768236289.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D10157.1768236289.diff
View Options
diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -1,5 +1,6 @@
// @flow
+import { siweAuthActionTypes } from './siwe-actions.js';
import threadWatcher from '../shared/thread-watcher.js';
import type {
LogOutResult,
@@ -475,6 +476,17 @@
const setAccessTokenActionType = 'SET_ACCESS_TOKEN';
+const logOutSuccessActions: $ReadOnlyArray<string> = [
+ logOutActionTypes.success,
+ deleteAccountActionTypes.success,
+];
+
+const logInSuccessActions: $ReadOnlyArray<string> = [
+ logInActionTypes.success,
+ siweAuthActionTypes.success,
+ registerActionTypes.success,
+];
+
export {
changeUserPasswordActionTypes,
changeUserPassword,
@@ -506,4 +518,6 @@
updateUserAvatar,
resetUserStateActionType,
setAccessTokenActionType,
+ logOutSuccessActions,
+ logInSuccessActions,
};
diff --git a/lib/reducers/loading-reducer.js b/lib/reducers/loading-reducer.js
--- a/lib/reducers/loading-reducer.js
+++ b/lib/reducers/loading-reducer.js
@@ -2,6 +2,10 @@
import _omit from 'lodash/fp/omit.js';
+import {
+ logOutSuccessActions,
+ logInSuccessActions,
+} from '../actions/user-actions.js';
import type { LoadingStatus } from '../types/loading-types.js';
import type { BaseAction } from '../types/redux-types.js';
import type { ActionTypes } from '../utils/action-utils.js';
@@ -13,10 +17,33 @@
fetchKeyRegistry.add(actionTypes.failed);
};
+const logOutActionsSet: Set<string> = new Set(
+ logOutSuccessActions
+ .map(actionName => {
+ const groups = actionName.match(/(.*)_SUCCESS/);
+ if (groups) {
+ return groups[1];
+ }
+ return undefined;
+ })
+ .filter(Boolean),
+);
+const logInActionsSet: Set<string> = new Set(logInSuccessActions);
+
function reduceLoadingStatuses(
state: { [key: string]: { [idx: number]: LoadingStatus } },
action: BaseAction,
): { [key: string]: { [idx: number]: LoadingStatus } } {
+ if (logInActionsSet.has(action.type)) {
+ const newState = { ...state };
+ for (const key in state) {
+ if (logOutActionsSet.has(key)) {
+ newState[key] = {};
+ }
+ }
+ state = newState;
+ }
+
const startMatch = action.type.match(/(.*)_STARTED/);
if (startMatch && fetchKeyRegistry.has(action.type)) {
if (!action.loadingInfo || typeof action.loadingInfo !== 'object') {
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
@@ -17,6 +17,7 @@
setUserSettingsActionTypes,
updateUserAvatarActionTypes,
resetUserStateActionType,
+ logInSuccessActions,
} from '../actions/user-actions.js';
import {
convertUserInfosToReplaceUserOps,
@@ -262,7 +263,11 @@
action.type,
onStateDifference,
);
- if (!_isEqual(state.userInfos)(newUserInfos)) {
+ const logInActionsSet = new Set(logInSuccessActions);
+ if (
+ logInActionsSet.has(action.type) ||
+ !_isEqual(state.userInfos)(newUserInfos)
+ ) {
return [
{
userInfos: newUserInfos,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 12, 4:44 PM (3 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5923939
Default Alt Text
D10157.1768236289.diff (3 KB)
Attached To
Mode
D10157: [lib] Fix Logout not working and state difference after invalid session downgrade
Attached
Detach File
Event Timeline
Log In to Comment