Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3385726
D10068.id33942.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D10068.id33942.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
@@ -61,7 +61,6 @@
MinimallyEncodedMemberInfo,
MinimallyEncodedRawThreadInfo,
MinimallyEncodedRelativeMemberInfo,
- MinimallyEncodedRoleInfo,
MinimallyEncodedThreadCurrentUserInfo,
MinimallyEncodedThreadInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
@@ -89,7 +88,7 @@
type ServerThreadInfo,
type RelativeMemberInfo,
type ThreadCurrentUserInfo,
- type LegacyRoleInfo,
+ type RoleInfo,
type ServerMemberInfo,
type ClientNewThreadRequest,
type NewThreadResult,
@@ -1170,9 +1169,7 @@
return !!memberInfo.permissions[threadPermissions.CHANGE_ROLE]?.value;
}
-function roleIsAdminRole(
- roleInfo: ?LegacyRoleInfo | ?MinimallyEncodedRoleInfo,
-): boolean {
+function roleIsAdminRole(roleInfo: ?RoleInfo): boolean {
return !!(roleInfo && !roleInfo.isDefault && roleInfo.name === 'Admins');
}
diff --git a/lib/types/thread-types.js b/lib/types/thread-types.js
--- a/lib/types/thread-types.js
+++ b/lib/types/thread-types.js
@@ -15,7 +15,10 @@
MessageTruncationStatuses,
RawMessageInfo,
} from './message-types.js';
-import type { MinimallyEncodedResolvedThreadInfo } from './minimally-encoded-thread-permissions-types.js';
+import type {
+ MinimallyEncodedResolvedThreadInfo,
+ MinimallyEncodedRoleInfo,
+} from './minimally-encoded-thread-permissions-types.js';
import {
type ThreadSubscription,
threadSubscriptionValidator,
@@ -74,6 +77,8 @@
isDefault: t.Boolean,
});
+export type RoleInfo = LegacyRoleInfo | MinimallyEncodedRoleInfo;
+
export type ThreadCurrentUserInfo = {
+role: ?string,
+permissions: ThreadPermissionsInfo,
diff --git a/lib/utils/role-utils.js b/lib/utils/role-utils.js
--- a/lib/utils/role-utils.js
+++ b/lib/utils/role-utils.js
@@ -6,7 +6,6 @@
import { threadInfoSelector } from '../selectors/thread-selectors.js';
import type {
MinimallyEncodedRelativeMemberInfo,
- MinimallyEncodedRoleInfo,
MinimallyEncodedThreadInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
import {
@@ -17,7 +16,7 @@
import type {
ThreadInfo,
RelativeMemberInfo,
- LegacyRoleInfo,
+ RoleInfo,
} from '../types/thread-types';
import { threadTypes } from '../types/thread-types-enum.js';
@@ -65,7 +64,7 @@
memberInfos: $ReadOnlyArray<
RelativeMemberInfo | MinimallyEncodedRelativeMemberInfo,
>,
-): $ReadOnlyMap<string, ?LegacyRoleInfo | ?MinimallyEncodedRoleInfo> {
+): $ReadOnlyMap<string, ?RoleInfo> {
// Our in-code system has chat-specific roles, while the
// user-surfaced system has roles only for communities. We retrieve roles
// from the top-level community thread for accuracy, with a rare fallback
@@ -80,10 +79,7 @@
community ? threadInfoSelector(state)[community] : null,
);
const topMostThreadInfo = communityThreadInfo || threadInfo;
- const roleMap = new Map<
- string,
- ?LegacyRoleInfo | ?MinimallyEncodedRoleInfo,
- >();
+ const roleMap = new Map<string, ?RoleInfo>();
if (topMostThreadInfo.type === threadTypes.GENESIS) {
memberInfos.forEach(memberInfo =>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 2:02 AM (21 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599000
Default Alt Text
D10068.id33942.diff (3 KB)
Attached To
Mode
D10068: [lib] Re-introduce `RoleInfo` (`[Legacy/MinimallyEncoded]RoleInfo`)
Attached
Detach File
Event Timeline
Log In to Comment