From e5327d59bf9feabde0721bf884cf43a84bce3b95 Mon Sep 17 00:00:00 2001 From: Ashoat Tevosyan Date: Fri, 13 Dec 2024 17:54:43 -0500 Subject: [PATCH] [lib] Deduplicate in getCandidateSidebarItemsForThreadList Summary: I made a mistake in D14154: I forgot to deduplicate the "general" and unread results. Depends on D14157 Test Plan: Confirm I no longer see duplicated candidate sidebar items Reviewers: varun, will Reviewed By: varun Subscribers: tomek Differential Revision: https://phab.comm.dev/D14158 --- lib/shared/sidebar-item-utils.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/shared/sidebar-item-utils.js b/lib/shared/sidebar-item-utils.js index c78427e1ac..40cf137ec7 100644 --- a/lib/shared/sidebar-item-utils.js +++ b/lib/shared/sidebar-item-utils.js @@ -167,10 +167,16 @@ async function getCandidateSidebarItemsForThreadList( topUnreadPromise, ]); - const topResults = [ - ...topGeneralResults.slice(0, maxReadSidebars), - ...topUnreadResults.slice(0, maxUnreadSidebars), - ]; + const topResults = topUnreadResults.slice(0, maxUnreadSidebars); + const topThreadIDs = new Set([ + ...topResults.map(result => result.threadInfo.id), + ]); + const generalResults = topGeneralResults.slice(0, maxReadSidebars); + for (const result of generalResults) { + if (!topThreadIDs.has(result.threadInfo.id)) { + topResults.push(result); + } + } return topResults.map(result => { const {