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 @@ -26,6 +26,7 @@ import ashoat from '../facts/ashoat.js'; import genesis from '../facts/genesis.js'; import { useLoggedInUserInfo } from '../hooks/account-hooks.js'; +import { hasPermission } from '../permissions/minimally-encoded-thread-permissions.js'; import { permissionLookup, getAllThreadPermissions, @@ -52,6 +53,7 @@ type RobotextMessageInfo, type ComposableMessageInfo, } from '../types/message-types.js'; +import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js'; import { userRelationshipStatus } from '../types/relationship-types.js'; import { threadPermissionPropagationPrefixes, @@ -108,7 +110,7 @@ import { pendingThreadIDRegex } from '../utils/validation-utils.js'; function threadHasPermission( - threadInfo: ?(ThreadInfo | RawThreadInfo), + threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo), permission: ThreadPermission, ): boolean { if (!threadInfo) { @@ -119,7 +121,9 @@ `${permission} can be disabled by a block, but threadHasPermission can't ` + 'check for a block on RawThreadInfo. Please pass in ThreadInfo instead!', ); - if (!threadInfo.currentUser.permissions[permission]) { + if (threadInfo.minimallyEncoded) { + return hasPermission(threadInfo.currentUser.permissions, permission); + } else if (!threadInfo.currentUser.permissions[permission]) { return false; } return threadInfo.currentUser.permissions[permission].value; @@ -1276,12 +1280,12 @@ messageCreatorRelationship && relationshipBlockedInEitherDirection(messageCreatorRelationship); - const hasPermission = threadHasPermission( + const hasCreateSidebarsPermission = threadHasPermission( threadInfo, threadPermissions.CREATE_SIDEBARS, ); - return hasPermission && !creatorRelationshipHasBlock; + return hasCreateSidebarsPermission && !creatorRelationshipHasBlock; } function useSidebarExistsOrCanBeCreated(