Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33334625
D10658.1768898362.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
D10658.1768898362.diff
View Options
diff --git a/lib/reducers/keyserver-reducer.js b/lib/reducers/keyserver-reducer.js
--- a/lib/reducers/keyserver-reducer.js
+++ b/lib/reducers/keyserver-reducer.js
@@ -15,6 +15,7 @@
keyserverAuthActionTypes,
logOutActionTypes,
deleteKeyserverAccountActionTypes,
+ deleteAccountActionTypes,
keyserverRegisterActionTypes,
logInActionTypes,
resetUserStateActionType,
@@ -309,7 +310,7 @@
};
} else if (
action.type === logOutActionTypes.success ||
- action.type === deleteKeyserverAccountActionTypes.success
+ action.type === deleteAccountActionTypes.success
) {
// We want to remove all keyservers but Ashoat's keyserver
const oldConnection = state.keyserverInfos[ashoatKeyserverID].connection;
@@ -330,6 +331,38 @@
...state,
keyserverInfos,
};
+ } else if (action.type === deleteKeyserverAccountActionTypes.success) {
+ const keyserverIDsToRemove = new Set<string>(action.payload.keyserverIDs);
+ const newKeyserverInfos: { ...KeyserverInfos } = {};
+
+ const { keyserverInfos } = state;
+
+ for (const keyserverID in keyserverInfos) {
+ if (!keyserverIDsToRemove.has(keyserverID)) {
+ newKeyserverInfos[keyserverID] = keyserverInfos[keyserverID];
+ continue;
+ }
+ if (keyserverID === ashoatKeyserverID) {
+ const oldConnection =
+ state.keyserverInfos[ashoatKeyserverID].connection;
+
+ newKeyserverInfos[ashoatKeyserverID] = {
+ ...state.keyserverInfos[ashoatKeyserverID],
+ connection: {
+ ...oldConnection,
+ connectionIssue: null,
+ queuedActivityUpdates: [],
+ lateResponses: [],
+ },
+ cookie: null,
+ };
+ }
+ }
+
+ return {
+ ...state,
+ keyserverInfos: newKeyserverInfos,
+ };
} else if (action.type === setLateResponseActionType) {
const { messageID, isLate, keyserverID } = action.payload;
const lateResponsesSet = new Set<number>(
diff --git a/lib/reducers/keyserver-reducer.test.js b/lib/reducers/keyserver-reducer.test.js
new file mode 100644
--- /dev/null
+++ b/lib/reducers/keyserver-reducer.test.js
@@ -0,0 +1,41 @@
+// @flow
+
+import reduceKeyserverStore from './keyserver-reducer.js';
+import { deleteKeyserverAccountActionTypes } from '../actions/user-actions.js';
+import { defaultKeyserverInfo } from '../types/keyserver-types.js';
+
+describe('reduceKeyserverStore', () => {
+ it('removes from the store keyservers the user has disconnected from', () => {
+ const oldKeyserverStore = {
+ keyserverInfos: {
+ ['0']: defaultKeyserverInfo('url1'),
+ ['100']: defaultKeyserverInfo('url2'),
+ ['200']: defaultKeyserverInfo('url3'),
+ },
+ };
+
+ const deleteAccountAction = {
+ type: deleteKeyserverAccountActionTypes.success,
+ payload: {
+ currentUserInfo: { anonymous: true },
+ preRequestUserState: {
+ cookiesAndSessions: {},
+ currentUserInfo: {
+ id: '1000',
+ username: 'test',
+ },
+ },
+ keyserverIDs: ['100', '200'],
+ },
+ loadingInfo: {
+ fetchIndex: 1,
+ trackMultipleRequests: false,
+ customKeyName: undefined,
+ },
+ };
+
+ expect(
+ reduceKeyserverStore(oldKeyserverStore, deleteAccountAction),
+ ).toEqual({ keyserverInfos: { ['0']: defaultKeyserverInfo('url1') } });
+ });
+});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 8:39 AM (9 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5960077
Default Alt Text
D10658.1768898362.diff (3 KB)
Attached To
Mode
D10658: [lib] Refactor logout in keyserver reducer
Attached
Detach File
Event Timeline
Log In to Comment