From 43347714fb4f78f56d80fabbcee4a0171a72d71c Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Tue, 12 Dec 2023 09:08:26 +0000 Subject: [PATCH] Fix case where channels could be shown in the wrong communities (#4988) --- .../home/communities/details/BrowseChannels.svelte | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/app/src/components/home/communities/details/BrowseChannels.svelte b/frontend/app/src/components/home/communities/details/BrowseChannels.svelte index 4f670f5077..94f3291377 100644 --- a/frontend/app/src/components/home/communities/details/BrowseChannels.svelte +++ b/frontend/app/src/components/home/communities/details/BrowseChannels.svelte @@ -13,6 +13,7 @@ $: selectedCommunity = client.selectedCommunity; $: chatSummariesListStore = client.chatSummariesListStore; + $: selectedCommunityId = $selectedCommunity?.id.communityId; let searching = false; let pageIndex = 0; @@ -28,11 +29,12 @@ $: filteredResults = searchResults.filter((c) => !myChannels.has(c.id)); function search(term: string, reset = false) { - if ($selectedCommunity === undefined) return; - if ($selectedCommunity.id.communityId !== matchedCommunityId) { + const communityId = selectedCommunityId; + if (communityId === undefined) return; + if (communityId !== matchedCommunityId) { searchResults = []; } - matchedCommunityId = $selectedCommunity.id.communityId; + matchedCommunityId = communityId; searching = true; if (reset) { pageIndex = 0; @@ -41,7 +43,7 @@ } client .exploreChannels( - $selectedCommunity.id, + { kind: "community", communityId }, term === "" ? undefined : term, pageIndex, pageSize, @@ -49,7 +51,7 @@ .then((results) => { if ( results.kind === "success" && - $selectedCommunity?.id.communityId === matchedCommunityId + communityId === matchedCommunityId ) { if (reset) { searchResults = results.matches; @@ -69,7 +71,7 @@ } $: { - if ($selectedCommunity !== undefined) { + if (selectedCommunityId !== undefined) { search(searchTerm, true); } else { searchResults = [];