Page MenuHomePhabricator

D11950.diff
No OneTemporary

D11950.diff

diff --git a/lib/hooks/child-threads.js b/lib/hooks/child-threads.js
--- a/lib/hooks/child-threads.js
+++ b/lib/hooks/child-threads.js
@@ -12,7 +12,7 @@
} from '../selectors/chat-selectors.js';
import { useGlobalThreadSearchIndex } from '../selectors/nav-selectors.js';
import { childThreadInfos } from '../selectors/thread-selectors.js';
-import { threadInChatList } from '../shared/thread-utils.js';
+import { useThreadsInChatList } from '../shared/thread-utils.js';
import threadWatcher from '../shared/thread-watcher.js';
import type {
ThreadInfo,
@@ -63,14 +63,24 @@
const searchTextExists = !!searchText.length;
+ const subchannelsThreadInfos = React.useMemo(
+ () => allSubchannelsList.map(item => item.threadInfo),
+ [allSubchannelsList],
+ );
+ const subchannelsInChatList = useThreadsInChatList(subchannelsThreadInfos);
+ const subchannelIDsInChatList = React.useMemo(
+ () => new Set(subchannelsInChatList.map(thread => thread.id)),
+ [subchannelsInChatList],
+ );
+
const subchannelIDsNotInChatList = React.useMemo(
() =>
new Set(
allSubchannelsList
- .filter(item => !threadInChatList(item.threadInfo))
+ .filter(item => !subchannelIDsInChatList.has(item.threadInfo.id))
.map(item => item.threadInfo.id),
),
- [allSubchannelsList],
+ [allSubchannelsList, subchannelIDsInChatList],
);
React.useEffect(() => {
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
@@ -219,6 +219,19 @@
return viewerIsMember(threadInfo) && threadIsVisible;
}
+function useThreadsInChatList(
+ threadInfos: $ReadOnlyArray<ThreadInfo>,
+): $ReadOnlyArray<ThreadInfo> {
+ const visibleThreads = useThreadsWithPermission(
+ threadInfos,
+ threadPermissions.VISIBLE,
+ );
+ return React.useMemo(
+ () => visibleThreads.filter(viewerIsMember),
+ [visibleThreads],
+ );
+}
+
function threadIsTopLevel(threadInfo: ?(RawThreadInfo | ThreadInfo)): boolean {
return threadInChatList(threadInfo) && threadIsChannel(threadInfo);
}
@@ -1938,6 +1951,7 @@
viewerIsMember,
threadInChatList,
useIsThreadInChatList,
+ useThreadsInChatList,
threadIsTopLevel,
threadIsChannel,
threadIsSidebar,

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 11:19 AM (21 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2600744
Default Alt Text
D11950.diff (2 KB)

Event Timeline