Page MenuHomePhabricator

D13886.id45633.diff
No OneTemporary

D13886.id45633.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
@@ -175,29 +175,27 @@
return communityRootMembersToRole;
}
+function threadIsThickOrChannelInsideGenesis(threadInfo: ThreadInfo): boolean {
+ if (threadTypeIsThick(threadInfo.type)) {
+ return true;
+ }
+ if (getCommunity(threadInfo) !== genesis().id) {
+ return false;
+ }
+ return threadInfo.id !== genesis().id;
+}
+
function useThreadsWithPermission(
threadInfos: $ReadOnlyArray<ThreadInfo>,
permission: ThreadPermission,
): $ReadOnlyArray<ThreadInfo> {
const loggedInUserInfo = useLoggedInUserInfo();
const userInfos = useSelector(state => state.userStore.userInfos);
- const allThreadInfos = useSelector(state => state.threadStore.threadInfos);
- const allThreadInfosArray = React.useMemo(
- () => values(allThreadInfos),
- [allThreadInfos],
- );
-
- const communityRootMembersToRole =
- useCommunityRootMembersToRole(allThreadInfosArray);
return React.useMemo(() => {
return threadInfos.filter((threadInfo: ThreadInfo) => {
- const membersToRole = communityRootMembersToRole[threadInfo.id];
- const memberHasAdminRole = threadMembersWithoutAddedAdmin(
- threadInfo,
- ).some(member => roleIsAdminRole(membersToRole?.[member.id]));
-
- if (memberHasAdminRole || !loggedInUserInfo) {
+ const isGroupChat = threadIsThickOrChannelInsideGenesis(threadInfo);
+ if (!isGroupChat || !loggedInUserInfo) {
return hasPermission(threadInfo.currentUser.permissions, permission);
}
@@ -214,13 +212,7 @@
return hasPermission(permissions, permission);
});
- }, [
- threadInfos,
- communityRootMembersToRole,
- loggedInUserInfo,
- userInfos,
- permission,
- ]);
+ }, [threadInfos, loggedInUserInfo, userInfos, permission]);
}
function useThreadHasPermission(

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 4:25 PM (19 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2576721
Default Alt Text
D13886.id45633.diff (1 KB)

Event Timeline