Skip to content

Commit

Permalink
Fix case where channels could be shown in the wrong communities (#4988)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 12, 2023
1 parent 13c874b commit 4334771
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
$: selectedCommunity = client.selectedCommunity;
$: chatSummariesListStore = client.chatSummariesListStore;
$: selectedCommunityId = $selectedCommunity?.id.communityId;
let searching = false;
let pageIndex = 0;
Expand All @@ -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;
Expand All @@ -41,15 +43,15 @@
}
client
.exploreChannels(
$selectedCommunity.id,
{ kind: "community", communityId },
term === "" ? undefined : term,
pageIndex,
pageSize,
)
.then((results) => {
if (
results.kind === "success" &&
$selectedCommunity?.id.communityId === matchedCommunityId
communityId === matchedCommunityId
) {
if (reset) {
searchResults = results.matches;
Expand All @@ -69,7 +71,7 @@
}
$: {
if ($selectedCommunity !== undefined) {
if (selectedCommunityId !== undefined) {
search(searchTerm, true);
} else {
searchResults = [];
Expand Down

0 comments on commit 4334771

Please sign in to comment.