Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3495794
D12329.id41106.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12329.id41106.diff
View Options
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/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,12 +2,14 @@
import * as React from 'react';
+import { processNewUserIDsActionType } from '../actions/user-actions.js';
import {
serverServerSocketMessageValidator,
type SocketListener,
type ClientServerSocketMessage,
} from '../types/socket-types.js';
import { extractUserIDsFromPayload } from '../utils/conversion-utils.js';
+import { useDispatch } from '../utils/redux-utils.js';
type Props = {
+addListener: (listener: SocketListener) => mixed,
@@ -17,14 +19,22 @@
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 dispatch = useDispatch();
+ const onMessage = React.useCallback(
+ (message: ClientServerSocketMessage) => {
+ const newUserIDs = extractUserIDsFromPayload(
+ serverServerSocketMessageValidator,
+ message,
+ );
+ if (newUserIDs.length > 0) {
+ dispatch({
+ type: processNewUserIDsActionType,
+ payload: { userIDs: newUserIDs },
+ });
+ }
+ },
+ [dispatch],
+ );
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,18 @@
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
+ if (newUserIDs.length > 0) {
+ dispatch({
+ type: processNewUserIDsActionType,
+ payload: { userIDs: newUserIDs },
+ });
+ }
}
export { extractAndPersistUserInfosFromEndpointResponse };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 9:59 AM (11 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2681373
Default Alt Text
D12329.id41106.diff (3 KB)
Attached To
Mode
D12329: [lib] Dispatch processNewUserIDsActionType
Attached
Detach File
Event Timeline
Log In to Comment