From 5cde7e55a5630a6fa4e5129ba1b7e935793373e7 Mon Sep 17 00:00:00 2001 From: Matt Grogan Date: Thu, 12 Oct 2023 16:24:27 +0100 Subject: [PATCH] Find rather than filter to select 1st element (#4569) --- frontend/app/src/components/home/Home.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/app/src/components/home/Home.svelte b/frontend/app/src/components/home/Home.svelte index c743b83736..b480e068c0 100644 --- a/frontend/app/src/components/home/Home.svelte +++ b/frontend/app/src/components/home/Home.svelte @@ -345,9 +345,9 @@ (pathParams.kind === "selected_community_route" || pathParams.kind === "chat_list_route") ) { - const unarchived = $chatSummariesListStore.filter((c) => !c.membership.archived); - if (unarchived.length > 0) { - page.redirect(routeForChatIdentifier($chatListScope.kind, unarchived[0].id)); + const first = $chatSummariesListStore.find((c) => !c.membership.archived); + if (first !== undefined) { + page.redirect(routeForChatIdentifier($chatListScope.kind, first.id)); return; } }