Page MenuHomePhabricator

D12329.id41035.diff
No OneTemporary

D12329.id41035.diff

diff --git a/lib/keyserver-conn/call-single-keyserver-endpoint.js b/lib/keyserver-conn/call-single-keyserver-endpoint.js
--- a/lib/keyserver-conn/call-single-keyserver-endpoint.js
+++ b/lib/keyserver-conn/call-single-keyserver-endpoint.js
@@ -202,7 +202,7 @@
json = await Promise.race([callEndpointPromise, rejectPromise]);
}
}
- extractAndPersistUserInfosFromEndpointResponse(json, endpoint);
+ extractAndPersistUserInfosFromEndpointResponse(json, endpoint, dispatch);
const { cookieChange, error, payload, currentUserInfo } = json;
const sessionChange: ?ServerSessionChange = cookieChange;
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
@@ -370,6 +370,7 @@
<SocketMessageUserInfosHandler
addListener={this.addListener}
removeListener={this.removeListener}
+ dispatch={this.props.dispatch}
/>
</React.Fragment>
);
diff --git a/lib/socket/user-infos-handler.react.js b/lib/socket/user-infos-handler.react.js
--- a/lib/socket/user-infos-handler.react.js
+++ b/lib/socket/user-infos-handler.react.js
@@ -2,6 +2,8 @@
import * as React from 'react';
+import { processNewUserIDsActionType } from '../actions/user-actions.js';
+import type { Dispatch } from '../types/redux-types.js';
import {
serverServerSocketMessageValidator,
type SocketListener,
@@ -12,19 +14,25 @@
type Props = {
+addListener: (listener: SocketListener) => mixed,
+removeListener: (listener: SocketListener) => mixed,
+ +dispatch: Dispatch,
};
export default function SocketMessageUserInfosHandler(
props: Props,
): React.Node {
- const onMessage = React.useCallback((message: ClientServerSocketMessage) => {
- // eslint-disable-next-line no-unused-vars
- const newUserIDs = extractUserIDsFromPayload(
- serverServerSocketMessageValidator,
- message,
- );
- // TODO: dispatch an action adding the new user ids to the UserStore
- }, []);
+ const onMessage = React.useCallback(
+ (message: ClientServerSocketMessage) => {
+ const newUserIDs = extractUserIDsFromPayload(
+ serverServerSocketMessageValidator,
+ message,
+ );
+ props.dispatch({
+ type: processNewUserIDsActionType,
+ payload: { userIDs: newUserIDs },
+ });
+ },
+ [props],
+ );
const { addListener, removeListener } = props;
diff --git a/lib/utils/user-info-extraction-utils.js b/lib/utils/user-info-extraction-utils.js
--- a/lib/utils/user-info-extraction-utils.js
+++ b/lib/utils/user-info-extraction-utils.js
@@ -3,9 +3,11 @@
import _memoize from 'lodash/memoize.js';
import t, { type TType, type TInterface } from 'tcomb';
+import { processNewUserIDsActionType } from '../actions/user-actions.js';
import type { CallSingleKeyserverEndpointResponse } from '../keyserver-conn/call-single-keyserver-endpoint.js';
import { mixedRawThreadInfoValidator } from '../permissions/minimally-encoded-raw-thread-info-validators.js';
import type { Endpoint } from '../types/endpoints.js';
+import type { Dispatch } from '../types/redux-types.js';
import type { MixedRawThreadInfos } from '../types/thread-types.js';
import { userInfoValidator } from '../types/user-types.js';
import type { UserInfo } from '../types/user-types.js';
@@ -73,13 +75,16 @@
function extractAndPersistUserInfosFromEndpointResponse(
message: CallSingleKeyserverEndpointResponse,
endpoint: Endpoint,
+ dispatch: Dispatch,
): void {
const extendedValidator = extendResponderValidator(
endpointValidators[endpoint].validator,
);
- // eslint-disable-next-line no-unused-vars
const newUserIDs = extractUserIDsFromPayload(extendedValidator, message);
- // TODO: dispatch an action adding the new user ids to the UserStore
+ dispatch({
+ type: processNewUserIDsActionType,
+ payload: { userIDs: newUserIDs },
+ });
}
export { extractAndPersistUserInfosFromEndpointResponse };

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 9:57 PM (17 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2681390
Default Alt Text
D12329.id41035.diff (3 KB)

Event Timeline