diff --git a/frontend/app/src/components/home/Home.svelte b/frontend/app/src/components/home/Home.svelte index b480e068c0..7aa87f3086 100644 --- a/frontend/app/src/components/home/Home.svelte +++ b/frontend/app/src/components/home/Home.svelte @@ -187,6 +187,12 @@ : "OpenChat"; } + $: { + tick().then(() => { + routeChange($chatsInitialised, $pathParams); + }); + } + onMount(() => { subscribeToNotifications(client, (n) => client.notificationReceived(n)); client.addEventListener("openchat_event", clientEvent); @@ -343,13 +349,12 @@ if ( !$mobileWidth && (pathParams.kind === "selected_community_route" || - pathParams.kind === "chat_list_route") + pathParams.kind === "chat_list_route") && + $chatSummariesListStore.length > 0 ) { - const first = $chatSummariesListStore.find((c) => !c.membership.archived); - if (first !== undefined) { - page.redirect(routeForChatIdentifier($chatListScope.kind, first.id)); - return; - } + const first = $chatSummariesListStore[0]; + page.redirect(routeForChatIdentifier($chatListScope.kind, first.id)); + return; } if (pathParams.kind === "home_route") { @@ -445,10 +450,6 @@ } } - $: { - routeChange($chatsInitialised, $pathParams); - } - // Note: very important (and hacky) that this is hidden in a function rather than inline in the top level reactive // statement because we don't want that reactive statement to execute in reponse to changes in rightPanelHistory :puke: function filterChatSpecificRightPanelStates() {