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 @@ -8,6 +8,7 @@ updateActivity, } from '../actions/activity-actions.js'; import { getMostRecentNonLocalMessageID } from '../shared/message-utils.js'; +import { threadIsPending } from '../shared/thread-utils.js'; import { queueActivityUpdatesActionType } from '../types/activity-types.js'; import { useServerCall, @@ -62,15 +63,19 @@ React.useEffect(() => { const activityUpdates = []; + const isActiveThreadPending = threadIsPending(activeThread); + if (activeThread !== prevActiveThread) { - if (prevActiveThread) { + const isPrevActiveThreadPending = threadIsPending(prevActiveThread); + + if (prevActiveThread && !isPrevActiveThreadPending) { activityUpdates.push({ focus: false, threadID: prevActiveThread, latestMessage: prevActiveThreadLatestMessage, }); } - if (activeThread) { + if (activeThread && !isActiveThreadPending) { activityUpdates.push({ focus: true, threadID: activeThread, @@ -83,7 +88,8 @@ !frozen && connectionStatus !== 'connected' && prevConnectionStatus === 'connected' && - activeThread + activeThread && + !isActiveThreadPending ) { // When the server closes a socket it also deletes any activity rows // associated with that socket's session. If that activity is still