Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32210735
D10661.1765132650.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
D10661.1765132650.diff
View Options
diff --git a/lib/reducers/thread-activity-reducer.js b/lib/reducers/thread-activity-reducer.js
--- a/lib/reducers/thread-activity-reducer.js
+++ b/lib/reducers/thread-activity-reducer.js
@@ -17,7 +17,9 @@
import {
logOutActionTypes,
deleteKeyserverAccountActionTypes,
+ deleteAccountActionTypes,
} from '../actions/user-actions.js';
+import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js';
import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js';
import type { BaseAction } from '../types/redux-types.js';
import { incrementalStateSyncActionType } from '../types/socket-types.js';
@@ -88,10 +90,23 @@
const { [update.threadID]: _, ...stateSansRemovedThread } = updatedState;
updatedState = stateSansRemovedThread;
}
+ return updatedState;
+ } else if (action.type === deleteKeyserverAccountActionTypes.success) {
+ let updatedState = { ...state };
+ const keyserverIDsSet = new Set<string>(action.payload.keyserverIDs);
+
+ for (const threadID in state) {
+ if (!keyserverIDsSet.has(extractKeyserverIDFromID(threadID))) {
+ continue;
+ }
+ const { [threadID]: _, ...stateSansRemovedThread } = updatedState;
+ updatedState = stateSansRemovedThread;
+ }
+
return updatedState;
} else if (
action.type === logOutActionTypes.success ||
- action.type === deleteKeyserverAccountActionTypes.success ||
+ action.type === deleteAccountActionTypes.success ||
(action.type === setNewSessionActionType &&
action.payload.sessionChange.cookieInvalidated)
) {
diff --git a/lib/reducers/thread-activity-reducer.test.js b/lib/reducers/thread-activity-reducer.test.js
--- a/lib/reducers/thread-activity-reducer.test.js
+++ b/lib/reducers/thread-activity-reducer.test.js
@@ -1,6 +1,7 @@
// @flow
import { reduceThreadActivity } from './thread-activity-reducer.js';
+import { deleteKeyserverAccountActionTypes } from '../actions/user-actions.js';
import { updateThreadLastNavigatedActionType } from '../types/thread-activity-types.js';
// NOTE: These unit tests were generated by GitHub Copilot.
@@ -66,4 +67,45 @@
const result = reduceThreadActivity(initialState, action);
expect(result).toEqual(expectedState);
});
+
+ test('removes threads of keyserver the user has disconnected from', () => {
+ const keyserver1 = '100';
+ const keyserver2 = '200';
+ const keyserver3 = '300';
+ const threads1 = {
+ [keyserver1 + '|1']: { lastNavigatedTo: 1, lastPruned: 1 },
+ [keyserver1 + '|2']: { lastNavigatedTo: 1, lastPruned: 1 },
+ };
+ const threads2 = {
+ [keyserver2 + '|1']: { lastNavigatedTo: 1, lastPruned: 1 },
+ [keyserver2 + '|2']: { lastNavigatedTo: 1, lastPruned: 1 },
+ };
+ const threads3 = {
+ [keyserver3 + '|1']: { lastNavigatedTo: 1, lastPruned: 1 },
+ [keyserver3 + '|2']: { lastNavigatedTo: 1, lastPruned: 1 },
+ };
+
+ const threads = { ...threads1, ...threads2, ...threads3 };
+ const action = {
+ type: deleteKeyserverAccountActionTypes.success,
+ payload: {
+ currentUserInfo: { anonymous: true },
+ preRequestUserState: {
+ cookiesAndSessions: {},
+ currentUserInfo: {
+ id: '83810',
+ username: 'user1',
+ },
+ },
+ keyserverIDs: [keyserver1, keyserver2],
+ },
+ loadingInfo: {
+ fetchIndex: 1,
+ trackMultipleRequests: false,
+ customKeyName: undefined,
+ },
+ };
+
+ expect(reduceThreadActivity(threads, action)).toEqual(threads3);
+ });
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 6:37 PM (20 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5845477
Default Alt Text
D10661.1765132650.diff (3 KB)
Attached To
Mode
D10661: [lib] Refactor logout in thread activity reducer
Attached
Detach File
Event Timeline
Log In to Comment