Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3369827
D9763.id33313.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D9763.id33313.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
@@ -3,7 +3,6 @@
import reduceConnectionInfo from './connection-reducer.js';
import { reduceDeviceToken } from './device-token-reducer.js';
import reduceLastCommunicatedPlatformDetails from './last-communicated-platform-details-reducer.js';
-import reduceUpdatesCurrentAsOf from './updates-reducer.js';
import {
addKeyserverActionType,
removeKeyserverActionType,
@@ -91,21 +90,57 @@
}
} else if (
action.type === logInActionTypes.success ||
- action.type === siweAuthActionTypes.success ||
- action.type === fullStateSyncActionType ||
- action.type === incrementalStateSyncActionType ||
- action.type === processUpdatesActionType
+ action.type === siweAuthActionTypes.success
) {
- const updatesCurrentAsOf = reduceUpdatesCurrentAsOf(
- state.keyserverInfos[ashoatKeyserverID].updatesCurrentAsOf,
- action,
+ const { updatesCurrentAsOf } = action.payload;
+ for (const keyserverID in updatesCurrentAsOf) {
+ state = {
+ ...state,
+ keyserverInfos: {
+ ...state.keyserverInfos,
+ [keyserverID]: {
+ ...state.keyserverInfos[keyserverID],
+ updatesCurrentAsOf: updatesCurrentAsOf[keyserverID],
+ },
+ },
+ };
+ }
+ } else if (action.type === fullStateSyncActionType) {
+ const { keyserverID } = action.payload;
+ state = {
+ ...state,
+ keyserverInfos: {
+ ...state.keyserverInfos,
+ [keyserverID]: {
+ ...state.keyserverInfos[keyserverID],
+ updatesCurrentAsOf: action.payload.updatesCurrentAsOf,
+ },
+ },
+ };
+ } else if (action.type === incrementalStateSyncActionType) {
+ const { keyserverID } = action.payload;
+ state = {
+ ...state,
+ keyserverInfos: {
+ ...state.keyserverInfos,
+ [keyserverID]: {
+ ...state.keyserverInfos[keyserverID],
+ updatesCurrentAsOf: action.payload.updatesResult.currentAsOf,
+ },
+ },
+ };
+ } else if (action.type === processUpdatesActionType) {
+ const { keyserverID } = action.payload;
+ const updatesCurrentAsOf = Math.max(
+ action.payload.updatesResult.currentAsOf,
+ state.keyserverInfos[keyserverID].updatesCurrentAsOf,
);
state = {
...state,
keyserverInfos: {
...state.keyserverInfos,
- [ashoatKeyserverID]: {
- ...state.keyserverInfos[ashoatKeyserverID],
+ [keyserverID]: {
+ ...state.keyserverInfos[keyserverID],
updatesCurrentAsOf,
},
},
diff --git a/lib/reducers/updates-reducer.js b/lib/reducers/updates-reducer.js
deleted file mode 100644
--- a/lib/reducers/updates-reducer.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// @flow
-
-import { siweAuthActionTypes } from '../actions/siwe-actions.js';
-import { logInActionTypes } from '../actions/user-actions.js';
-import type { BaseAction } from '../types/redux-types.js';
-import {
- fullStateSyncActionType,
- incrementalStateSyncActionType,
-} from '../types/socket-types.js';
-import { processUpdatesActionType } from '../types/update-types.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
-
-function reduceUpdatesCurrentAsOf(
- currentAsOf: number,
- action: BaseAction,
-): number {
- if (
- action.type === logInActionTypes.success ||
- action.type === siweAuthActionTypes.success
- ) {
- return action.payload.updatesCurrentAsOf[ashoatKeyserverID];
- } else if (action.type === fullStateSyncActionType) {
- return action.payload.updatesCurrentAsOf;
- } else if (action.type === incrementalStateSyncActionType) {
- return action.payload.updatesResult.currentAsOf;
- } else if (action.type === processUpdatesActionType) {
- return Math.max(action.payload.updatesResult.currentAsOf, currentAsOf);
- }
- return currentAsOf;
-}
-
-export default reduceUpdatesCurrentAsOf;
diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js
--- a/lib/socket/socket.react.js
+++ b/lib/socket/socket.react.js
@@ -352,6 +352,7 @@
sendMessage={this.sendMessageWithoutID}
addListener={this.addListener}
removeListener={this.removeListener}
+ keyserverID={ashoatKeyserverID}
/>
<MessageHandler
addListener={this.addListener}
@@ -621,6 +622,7 @@
payload: {
...actionPayload,
calendarQuery: sessionState.calendarQuery,
+ keyserverID: ashoatKeyserverID,
},
});
if (sessionID !== null && sessionID !== undefined) {
@@ -646,6 +648,7 @@
payload: {
...actionPayload,
calendarQuery: sessionState.calendarQuery,
+ keyserverID: ashoatKeyserverID,
},
});
}
diff --git a/lib/socket/update-handler.react.js b/lib/socket/update-handler.react.js
--- a/lib/socket/update-handler.react.js
+++ b/lib/socket/update-handler.react.js
@@ -21,9 +21,10 @@
+sendMessage: (message: ClientSocketMessageWithoutID) => number,
+addListener: (listener: SocketListener) => void,
+removeListener: (listener: SocketListener) => void,
+ +keyserverID: string,
};
export default function UpdateHandler(props: Props): React.Node {
- const { addListener, removeListener, sendMessage } = props;
+ const { addListener, removeListener, sendMessage, keyserverID } = props;
const dispatch = useDispatch();
const connection = useSelector(connectionSelector(ashoatKeyserverID));
@@ -36,7 +37,7 @@
}
dispatch({
type: processUpdatesActionType,
- payload: message.payload,
+ payload: { ...message.payload, keyserverID },
});
if (connectionStatus !== 'connected') {
return;
@@ -48,7 +49,7 @@
},
});
},
- [connectionStatus, dispatch, sendMessage],
+ [connectionStatus, dispatch, keyserverID, sendMessage],
);
useEffect(() => {
addListener(onMessage);
diff --git a/lib/types/socket-types.js b/lib/types/socket-types.js
--- a/lib/types/socket-types.js
+++ b/lib/types/socket-types.js
@@ -203,6 +203,7 @@
export type StateSyncFullActionPayload = {
...ClientFullStateSync,
+calendarQuery: CalendarQuery,
+ +keyserverID: string,
};
export type ClientStateSyncFullSocketPayload = {
...ClientFullStateSync,
@@ -254,6 +255,7 @@
export type StateSyncIncrementalActionPayload = {
...ClientIncrementalStateSync,
+calendarQuery: CalendarQuery,
+ +keyserverID: string,
};
type ClientStateSyncIncrementalSocketPayload = {
+type: 1,
diff --git a/lib/types/update-types.js b/lib/types/update-types.js
--- a/lib/types/update-types.js
+++ b/lib/types/update-types.js
@@ -282,6 +282,7 @@
export type ClientUpdatesResultWithUserInfos = {
+updatesResult: ClientUpdatesResult,
+userInfos: $ReadOnlyArray<UserInfo>,
+ +keyserverID: string,
};
export type CreateUpdatesResult = {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 11:37 PM (22 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2586926
Default Alt Text
D9763.id33313.diff (6 KB)
Attached To
Mode
D9763: [lib] Inline reduceUpdatesCurrentAsOf
Attached
Detach File
Event Timeline
Log In to Comment