Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3333588
D13886.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
D13886.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
@@ -175,29 +175,36 @@
return communityRootMembersToRole;
}
+// This function returns true for all thick threads, as well as all channels
+// inside GENESIS. Channels inside GENESIS were used in place of thick threads
+// before thick threads were launched, and as such we mirror "freezing" behavior
+// between them and thick threads. "Freezing" a thread can occur when a user
+// blocks another user, and those two users are the only members of a given
+// chat. Note that we exclude the GENESIS community root here, as the root
+// itself has never been used in place of thick threads. Also note that
+// grandchild channels of GENESIS get this behavior too, even though we don't
+// currently support channels inside thick threads.
+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 +221,7 @@
return hasPermission(permissions, permission);
});
- }, [
- threadInfos,
- communityRootMembersToRole,
- loggedInUserInfo,
- userInfos,
- permission,
- ]);
+ }, [threadInfos, loggedInUserInfo, userInfos, permission]);
}
function useThreadHasPermission(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 4:36 AM (19 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2559944
Default Alt Text
D13886.diff (2 KB)
Attached To
Mode
D13886: [lib] Fix useThreadsWithPermission check
Attached
Detach File
Event Timeline
Log In to Comment