Skip to content

Commit

Permalink
make sure that we always select the first channel if possible (#5725)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs authored Apr 25, 2024
1 parent 46a6d35 commit f16fbdd
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions frontend/app/src/components/home/Home.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,17 @@
return found;
}
function selectFirstChat(): boolean {
if (!$mobileWidth) {
const first = $chatSummariesListStore.find((c) => !c.membership.archived);
if (first !== undefined) {
page.redirect(routeForChatIdentifier($chatListScope.kind, first.id));
return true;
}
}
return false;
}
// extracting to a function to try to control more tightly what this reacts to
async function routeChange(initialised: boolean, pathParams: RouteParams): Promise<void> {
// wait until we have loaded the chats
Expand All @@ -408,16 +419,8 @@
}
// When we have a middle panel and this route is for a chat list then select the first chat
if (
!$mobileWidth &&
(pathParams.kind === "selected_community_route" ||
pathParams.kind === "chat_list_route")
) {
const first = $chatSummariesListStore.find((c) => !c.membership.archived);
if (first !== undefined) {
page.redirect(routeForChatIdentifier($chatListScope.kind, first.id));
return;
}
if (pathParams.kind === "chat_list_route" && selectFirstChat()) {
return;
}
if (pathParams.kind === "home_route") {
Expand All @@ -429,6 +432,9 @@
rightPanelHistory.set($fullWidth ? [{ kind: "community_filters" }] : []);
} else if (pathParams.kind === "selected_community_route") {
await selectCommunity(pathParams.communityId);
if (selectFirstChat()) {
return;
}
} else if (
pathParams.kind === "global_chat_selected_route" ||
pathParams.kind === "selected_channel_route"
Expand Down

0 comments on commit f16fbdd

Please sign in to comment.