Page MenuHomePhabricator

D13719.id45241.diff
No OneTemporary

D13719.id45241.diff

diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -30,7 +30,10 @@
getAllThreadPermissions,
makePermissionsBlob,
} from '../permissions/thread-permissions.js';
-import type { ChatThreadItem } from '../selectors/chat-selectors.js';
+import type {
+ ChatThreadItem,
+ SidebarItem,
+} from '../selectors/chat-selectors.js';
import {
threadInfoSelector,
pendingToRealizedThreadIDsSelector,
@@ -1416,6 +1419,48 @@
return null;
}
+function getSearchResultsForEmptySearchText(
+ chatListData: $ReadOnlyArray<ChatThreadItem>,
+ threadFilter: ThreadInfo => boolean,
+): $ReadOnlyArray<ChatThreadItem> {
+ const threadHomeSubscriptions = Object.fromEntries(
+ chatListData.map(chatThreadItem => [
+ chatThreadItem.threadInfo.id,
+ threadIsInHome(chatThreadItem.threadInfo),
+ ]),
+ );
+
+ return chatListData
+ .filter((item: ChatThreadItem) => {
+ const threadInfo = item.threadInfo;
+ const { parentThreadID } = threadInfo;
+ const isThreadInHome = threadIsInHome(threadInfo);
+
+ if (threadIsSidebar(threadInfo) && parentThreadID) {
+ const isParentInHome = threadHomeSubscriptions[parentThreadID];
+ if (isParentInHome === isThreadInHome) {
+ return false;
+ }
+ }
+ return threadInChatList(threadInfo) && threadFilter(threadInfo);
+ })
+ .map((item: ChatThreadItem) => {
+ if (threadIsSidebar(item.threadInfo)) {
+ return item;
+ }
+ const sidebarsOnlyInSameTab = item.sidebars.filter(
+ (sidebar: SidebarItem) =>
+ sidebar.type !== 'sidebar' ||
+ threadIsInHome(sidebar.threadInfo) ===
+ threadIsInHome(item.threadInfo),
+ );
+ return {
+ ...item,
+ sidebars: sidebarsOnlyInSameTab,
+ };
+ });
+}
+
function getThreadListSearchResults(
chatListData: $ReadOnlyArray<ChatThreadItem>,
searchText: string,
@@ -1425,10 +1470,7 @@
loggedInUserInfo: ?LoggedInUserInfo,
): $ReadOnlyArray<ChatThreadItem> {
if (!searchText) {
- return chatListData.filter(
- item =>
- threadIsTopLevel(item.threadInfo) && threadFilter(item.threadInfo),
- );
+ return getSearchResultsForEmptySearchText(chatListData, threadFilter);
}
const privateThreads = [];

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 10:15 PM (20 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581128
Default Alt Text
D13719.id45241.diff (2 KB)

Event Timeline