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 @@ ); 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,27 @@ 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, + ); + if (newUserIDs.length > 0) { + 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,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 };