Skip to content

Commit

Permalink
[keyserver] Show the most recent thread when opening the web app with…
Browse files Browse the repository at this point in the history
…out providing a thread ID

Summary:
The most recent thread can be thick and the keyserver doesn't know about it. In this case we can rely on the app to compute the `activeChatThreadID` instead of the keyserver. In `validateStateAndQueueOpsProcessing` we're handling an empty `state.navInfo.activeChatThreadID` by calling `mostRecentlyReadThreadSelector`. This means that we can simply stop handling empty `activeChatThreadID` on the keyserver side.

https://linear.app/comm/issue/ENG-9126/opening-a-link-to-the-chat-doesnt-open-the-most-recent-thick-thread

Test Plan:
Made sure that the most recent thread is thick. Opened `/webapp` and `/webapp/chat` and verified that the most recent thread is shown.
Updated the state so that a thin thread is the most recent and performed the same test.
Made sure that opening a link to a thin and to a thick thread still opens it even if it isn't the most recent.

Reviewers: kamil, inka

Reviewed By: inka

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D13590
  • Loading branch information
palys-swm committed Oct 4, 2024
1 parent ee7e376 commit fdbf76f
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions keyserver/src/responders/redux-state-responders.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import t, { type TInterface } from 'tcomb';
import { baseLegalPolicies } from 'lib/facts/policies.js';
import { daysToEntriesFromEntryInfos } from 'lib/reducers/entry-reducer.js';
import { freshMessageStore } from 'lib/reducers/message-reducer.js';
import { mostRecentlyReadThread } from 'lib/selectors/thread-selectors.js';
import { mostRecentMessageTimestamp } from 'lib/shared/message-utils.js';
import {
threadHasPermission,
Expand Down Expand Up @@ -237,19 +236,13 @@ async function getInitialReduxStateResponder(
})();

const navInfoPromise = (async () => {
const [
{ threadInfos },
messageStore,
currentUserInfo,
userInfos,
finalNavInfo,
] = await Promise.all([
threadInfoPromise,
messageStorePromise,
currentUserInfoPromise,
userInfosPromise,
initialNavInfoPromise,
]);
const [{ threadInfos }, currentUserInfo, userInfos, finalNavInfo] =
await Promise.all([
threadInfoPromise,
currentUserInfoPromise,
userInfosPromise,
initialNavInfoPromise,
]);

const requestedActiveChatThreadID = finalNavInfo.activeChatThreadID;
if (
Expand All @@ -263,16 +256,6 @@ async function getInitialReduxStateResponder(
finalNavInfo.activeChatThreadID = null;
}

if (!finalNavInfo.activeChatThreadID) {
const mostRecentThread = mostRecentlyReadThread(
messageStore,
threadInfos,
);
if (mostRecentThread) {
finalNavInfo.activeChatThreadID = mostRecentThread;
}
}

const curActiveChatThreadID = finalNavInfo.activeChatThreadID;
if (
curActiveChatThreadID &&
Expand Down

0 comments on commit fdbf76f

Please sign in to comment.