diff --git a/lib/socket/activity-handler.react.js b/lib/socket/activity-handler.react.js
--- a/lib/socket/activity-handler.react.js
+++ b/lib/socket/activity-handler.react.js
@@ -7,6 +7,7 @@
updateActivityActionTypes,
useUpdateActivity,
} from '../actions/activity-actions.js';
+import { extractKeyserverIDFromID } from '../keyserver-conn/keyserver-call-utils.js';
import { connectionSelector } from '../selectors/keyserver-selectors.js';
import { getMostRecentNonLocalMessageID } from '../shared/message-utils.js';
import { threadIsPending } from '../shared/thread-utils.js';
@@ -17,14 +18,14 @@
import type { ConnectionStatus } from '../types/socket-types.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector, useDispatch } from '../utils/redux-utils.js';
-import { ashoatKeyserverID } from '../utils/validation-utils.js';
type Props = {
+activeThread: ?string,
+frozen: boolean,
+ +keyserverID: string,
};
function ActivityHandler(props: Props): React.Node {
- const { activeThread, frozen } = props;
+ const { activeThread, frozen, keyserverID } = props;
const prevActiveThreadRef = React.useRef();
React.useEffect(() => {
@@ -32,7 +33,7 @@
}, [activeThread]);
const prevActiveThread = prevActiveThreadRef.current;
- const connection = useSelector(connectionSelector(ashoatKeyserverID));
+ const connection = useSelector(connectionSelector(keyserverID));
invariant(connection, 'keyserver missing from keyserverStore');
const connectionStatus = connection.status;
const prevConnectionStatusRef = React.useRef();
@@ -72,14 +73,22 @@
if (activeThread !== prevActiveThread) {
const isPrevActiveThreadPending = threadIsPending(prevActiveThread);
- if (prevActiveThread && !isPrevActiveThreadPending) {
+ if (
+ prevActiveThread &&
+ !isPrevActiveThreadPending &&
+ extractKeyserverIDFromID(prevActiveThread) === keyserverID
+ ) {
activityUpdates.push({
focus: false,
threadID: prevActiveThread,
latestMessage: prevActiveThreadLatestMessage,
});
}
- if (activeThread && !isActiveThreadPending) {
+ if (
+ activeThread &&
+ !isActiveThreadPending &&
+ extractKeyserverIDFromID(activeThread) === keyserverID
+ ) {
activityUpdates.push({
focus: true,
threadID: activeThread,
@@ -93,7 +102,8 @@
connectionStatus !== 'connected' &&
prevConnectionStatus === 'connected' &&
activeThread &&
- !isActiveThreadPending
+ !isActiveThreadPending &&
+ extractKeyserverIDFromID(activeThread) === keyserverID
) {
// When the server closes a socket it also deletes any activity rows
// associated with that socket's session. If that activity is still
@@ -109,7 +119,7 @@
if (activityUpdates.length > 0) {
dispatch({
type: queueActivityUpdatesActionType,
- payload: { activityUpdates, keyserverID: ashoatKeyserverID },
+ payload: { activityUpdates, keyserverID },
});
}
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
@@ -349,6 +349,7 @@