Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33078395
D12329.1768450295.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D12329.1768450295.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
Thu, Jan 15, 4:11 AM (3 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5935855
Default Alt Text
D12329.1768450295.diff (3 KB)
Attached To
Mode
D12329: [lib] Dispatch processNewUserIDsActionType
Attached
Detach File
Event Timeline
Log In to Comment