Page MenuHomePhabricator

D12052.id40407.diff
No OneTemporary

D12052.id40407.diff

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

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)

Event Timeline