Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32555991
D12329.1767212221.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D12329.1767212221.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/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,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 };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 31, 8:17 PM (34 m, 15 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5874388
Default Alt Text
D12329.1767212221.diff (4 KB)
Attached To
Mode
D12329: [lib] Dispatch processNewUserIDsActionType
Attached
Detach File
Event Timeline
Log In to Comment