Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3507397
D12052.id40407.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12052.id40407.diff
View Options
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
@@ -12,6 +12,7 @@
import MessageHandler from './message-handler.react.js';
import RequestResponseHandler from './request-response-handler.react.js';
import UpdateHandler from './update-handler.react.js';
+import SocketMessageUserInfosHandler from './user-infos-handler.react.js';
import { updateActivityActionTypes } from '../actions/activity-actions.js';
import { updateLastCommunicatedPlatformDetailsActionType } from '../actions/device-actions.js';
import {
@@ -366,6 +367,10 @@
frozen={this.props.frozen}
keyserverID={this.props.keyserverID}
/>
+ <SocketMessageUserInfosHandler
+ addListener={this.addListener}
+ removeListener={this.removeListener}
+ />
</React.Fragment>
);
}
diff --git a/lib/socket/user-infos-handler.react.js b/lib/socket/user-infos-handler.react.js
new file mode 100644
--- /dev/null
+++ b/lib/socket/user-infos-handler.react.js
@@ -0,0 +1,39 @@
+// @flow
+
+import * as React from 'react';
+
+import {
+ serverServerSocketMessageValidator,
+ type SocketListener,
+ type ClientServerSocketMessage,
+} from '../types/socket-types.js';
+import { extractUserIDsFromPayload } from '../utils/conversion-utils.js';
+
+type Props = {
+ +addListener: (listener: SocketListener) => mixed,
+ +removeListener: (listener: SocketListener) => mixed,
+};
+
+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 { addListener, removeListener } = props;
+
+ React.useEffect(() => {
+ addListener(onMessage);
+ return () => {
+ removeListener(onMessage);
+ };
+ }, [addListener, removeListener, onMessage]);
+
+ return null;
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 8:40 PM (21 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2688610
Default Alt Text
D12052.id40407.diff (2 KB)
Attached To
Mode
D12052: [lib] Extract user ids from server socket messages
Attached
Detach File
Event Timeline
Log In to Comment