Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3355500
D10773.id36383.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D10773.id36383.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
@@ -49,7 +49,10 @@
export default function reduceKeyserverStore(
state: KeyserverStore,
action: BaseAction,
-): KeyserverStore {
+): {
+ keyserverStore: KeyserverStore,
+ keyserverStoreOperations: $ReadOnlyArray<KeyserverStoreOperation>,
+} {
if (action.type === addKeyserverActionType) {
const replaceOperation: ReplaceKeyserverOperation = {
type: 'replace_keyserver',
@@ -62,8 +65,13 @@
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [replaceOperation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [
+ replaceOperation,
+ ]),
+ },
+ keyserverStoreOperations: [replaceOperation],
};
} else if (action.type === removeKeyserverActionType) {
const removeOperation: RemoveKeyserversOperation = {
@@ -74,8 +82,13 @@
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [removeOperation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [
+ removeOperation,
+ ]),
+ },
+ keyserverStoreOperations: [removeOperation],
};
} else if (action.type === resetUserStateActionType) {
// this action is only dispatched on native
@@ -98,8 +111,14 @@
}
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, replaceOperations),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(
+ state.keyserverInfos,
+ replaceOperations,
+ ),
+ },
+ keyserverStoreOperations: replaceOperations,
};
} else if (action.type === setNewSessionActionType) {
const { keyserverID, sessionChange } = action.payload;
@@ -110,7 +129,10 @@
`but keyserver ${keyserverID} is not in KeyserverStore!`,
);
}
- return state;
+ return {
+ keyserverStore: state,
+ keyserverStoreOperations: [],
+ };
}
let newKeyserverInfo = {
@@ -148,8 +170,11 @@
}
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ },
+ keyserverStoreOperations: operations,
};
} else if (
action.type === logInActionTypes.success ||
@@ -173,8 +198,11 @@
});
}
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ },
+ keyserverStoreOperations: operations,
};
} else if (action.type === fullStateSyncActionType) {
const { keyserverID } = action.payload;
@@ -190,8 +218,11 @@
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === incrementalStateSyncActionType) {
const { keyserverID } = action.payload;
@@ -218,8 +249,11 @@
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === processUpdatesActionType) {
const { keyserverID } = action.payload;
@@ -238,8 +272,11 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === setURLPrefix) {
const operation: ReplaceKeyserverOperation = {
@@ -253,8 +290,11 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === updateLastCommunicatedPlatformDetailsActionType) {
const { keyserverID, platformDetails } = action.payload;
@@ -269,8 +309,11 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === keyserverRegisterActionTypes.success) {
const operation: ReplaceKeyserverOperation = {
@@ -284,8 +327,11 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === updateConnectionStatusActionType) {
const { keyserverID, status } = action.payload;
@@ -304,8 +350,11 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === unsupervisedBackgroundActionType) {
const { keyserverID } = action.payload;
@@ -324,8 +373,11 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === queueActivityUpdatesActionType) {
const { activityUpdates, keyserverID } = action.payload;
@@ -362,8 +414,11 @@
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === updateActivityActionTypes.success) {
const { activityUpdates } = action.payload;
@@ -388,8 +443,11 @@
});
}
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ },
+ keyserverStoreOperations: operations,
};
} else if (
action.type === logOutActionTypes.success ||
@@ -417,8 +475,11 @@
});
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ },
+ keyserverStoreOperations: operations,
};
} else if (action.type === deleteKeyserverAccountActionTypes.success) {
const operations: KeyserverStoreOperation[] = [
@@ -448,8 +509,11 @@
}
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ },
+ keyserverStoreOperations: operations,
};
} else if (action.type === setLateResponseActionType) {
const { messageID, isLate, keyserverID } = action.payload;
@@ -476,8 +540,11 @@
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === updateDisconnectedBarActionType) {
const { keyserverID } = action.payload;
@@ -495,8 +562,11 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
} else if (action.type === setDeviceTokenActionTypes.success) {
const { deviceTokens } = action.payload;
@@ -514,8 +584,11 @@
});
}
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, operations),
+ },
+ keyserverStoreOperations: operations,
};
} else if (action.type === setConnectionIssueActionType) {
const { connectionIssue, keyserverID } = action.payload;
@@ -533,10 +606,16 @@
},
};
return {
- ...state,
- keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ keyserverStore: {
+ ...state,
+ keyserverInfos: processStoreOps(state.keyserverInfos, [operation]),
+ },
+ keyserverStoreOperations: [operation],
};
}
- return state;
+ return {
+ keyserverStore: state,
+ keyserverStoreOperations: [],
+ };
}
diff --git a/lib/reducers/keyserver-reducer.test.js b/lib/reducers/keyserver-reducer.test.js
--- a/lib/reducers/keyserver-reducer.test.js
+++ b/lib/reducers/keyserver-reducer.test.js
@@ -35,7 +35,8 @@
};
expect(
- reduceKeyserverStore(oldKeyserverStore, deleteAccountAction),
+ reduceKeyserverStore(oldKeyserverStore, deleteAccountAction)
+ .keyserverStore,
).toEqual({ keyserverInfos: { ['0']: defaultKeyserverInfo('url1') } });
});
});
diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js
--- a/lib/reducers/master-reducer.js
+++ b/lib/reducers/master-reducer.js
@@ -77,7 +77,7 @@
reduceMessageStore(state.messageStore, action, threadInfos);
let messageStore = reducedMessageStore;
- let keyserverStore = reduceKeyserverStore(state.keyserverStore, action);
+ let { keyserverStore } = reduceKeyserverStore(state.keyserverStore, action);
if (
action.type !== incrementalStateSyncActionType &&
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 2:36 PM (21 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2576367
Default Alt Text
D10773.id36383.diff (10 KB)
Attached To
Mode
D10773: [lib] refactor `reduceKeyserverStore` to return ops
Attached
Detach File
Event Timeline
Log In to Comment