Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3337148
D13719.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13719.diff
View Options
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,52 @@
return null;
}
+function getSearchResultsForEmptySearchText(
+ chatListData: $ReadOnlyArray<ChatThreadItem>,
+ threadFilter: ThreadInfo => boolean,
+): Array<ChatThreadItem> {
+ const threadHomeSubscriptions = Object.fromEntries(
+ chatListData.map(chatThreadItem => [
+ chatThreadItem.threadInfo.id,
+ threadIsInHome(chatThreadItem.threadInfo),
+ ]),
+ );
+
+ return chatListData
+ .filter((item: ChatThreadItem) => {
+ const { threadInfo } = item;
+ const { parentThreadID } = threadInfo;
+ const isInFilteredChatList =
+ threadInChatList(threadInfo) && threadFilter(threadInfo);
+
+ if (!isInFilteredChatList) {
+ return false;
+ }
+ if (!threadIsSidebar(threadInfo) || !parentThreadID) {
+ return true;
+ }
+ const isParentInHome = threadHomeSubscriptions[parentThreadID];
+ const isThreadInHome = threadIsInHome(threadInfo);
+
+ return isParentInHome !== isThreadInHome;
+ })
+ .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 +1474,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
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 3:48 PM (17 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2562476
Default Alt Text
D13719.diff (2 KB)
Attached To
Mode
D13719: [lib] Show sidebars in top level if parent thread is in a separate tab
Attached
Detach File
Event Timeline
Log In to Comment