Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3524888
D9811.id33101.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D9811.id33101.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
@@ -53,7 +53,11 @@
type RobotextMessageInfo,
type ComposableMessageInfo,
} from '../types/message-types.js';
-import type { MinimallyEncodedRawThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
+import type {
+ MinimallyEncodedMemberInfo,
+ MinimallyEncodedRawThreadInfo,
+ MinimallyEncodedRoleInfo,
+} from '../types/minimally-encoded-thread-permissions-types.js';
import { userRelationshipStatus } from '../types/relationship-types.js';
import {
threadPermissionPropagationPrefixes,
@@ -129,7 +133,9 @@
return threadInfo.currentUser.permissions[permission].value;
}
-function viewerIsMember(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {
+function viewerIsMember(
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
+): boolean {
return !!(
threadInfo &&
threadInfo.currentUser.role !== null &&
@@ -137,38 +143,48 @@
);
}
-function threadIsInHome(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {
+function threadIsInHome(
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
+): boolean {
return !!(threadInfo && threadInfo.currentUser.subscription.home);
}
// Can have messages
-function threadInChatList(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {
+function threadInChatList(
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
+): boolean {
return (
viewerIsMember(threadInfo) &&
threadHasPermission(threadInfo, threadPermissions.VISIBLE)
);
}
-function threadIsTopLevel(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {
+function threadIsTopLevel(
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
+): boolean {
return threadInChatList(threadInfo) && threadIsChannel(threadInfo);
}
-function threadIsChannel(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {
+function threadIsChannel(
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
+): boolean {
return !!(threadInfo && threadInfo.type !== threadTypes.SIDEBAR);
}
-function threadIsSidebar(threadInfo: ?(ThreadInfo | RawThreadInfo)): boolean {
+function threadIsSidebar(
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
+): boolean {
return threadInfo?.type === threadTypes.SIDEBAR;
}
function threadInBackgroundChatList(
- threadInfo: ?(ThreadInfo | RawThreadInfo),
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
): boolean {
return threadInChatList(threadInfo) && !threadIsInHome(threadInfo);
}
function threadInHomeChatList(
- threadInfo: ?(ThreadInfo | RawThreadInfo),
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
): boolean {
return threadInChatList(threadInfo) && threadIsInHome(threadInfo);
}
@@ -176,7 +192,7 @@
// Can have Calendar entries,
// does appear as a top-level entity in the thread list
function threadInFilterList(
- threadInfo: ?(ThreadInfo | RawThreadInfo),
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
): boolean {
return (
threadInChatList(threadInfo) &&
@@ -186,7 +202,7 @@
}
function userIsMember(
- threadInfo: ?(ThreadInfo | RawThreadInfo),
+ threadInfo: ?(ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo),
userID: string,
): boolean {
if (!threadInfo) {
@@ -199,25 +215,26 @@
}
function threadActualMembers(
- memberInfos: $ReadOnlyArray<MemberInfo | RelativeMemberInfo>,
+ memberInfos: $ReadOnlyArray<
+ MemberInfo | RelativeMemberInfo | MinimallyEncodedMemberInfo,
+ >,
): $ReadOnlyArray<string> {
return memberInfos
.filter(memberInfo => memberInfo.role)
.map(memberInfo => memberInfo.id);
}
-function threadOtherMembers<T: MemberInfo | RelativeMemberInfo>(
- memberInfos: $ReadOnlyArray<T>,
- viewerID: ?string,
-): $ReadOnlyArray<T> {
+function threadOtherMembers<
+ T: MemberInfo | RelativeMemberInfo | MinimallyEncodedMemberInfo,
+>(memberInfos: $ReadOnlyArray<T>, viewerID: ?string): $ReadOnlyArray<T> {
return memberInfos.filter(
memberInfo => memberInfo.role && memberInfo.id !== viewerID,
);
}
-function threadMembersWithoutAddedAshoat<T: ThreadInfo | RawThreadInfo>(
- threadInfo: T,
-): $PropertyType<T, 'members'> {
+function threadMembersWithoutAddedAshoat<
+ T: ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo,
+>(threadInfo: T): $PropertyType<T, 'members'> {
if (threadInfo.community !== genesis.id) {
return threadInfo.members;
}
@@ -231,7 +248,7 @@
}
function threadOrParentThreadIsGroupChat(
- threadInfo: RawThreadInfo | ThreadInfo,
+ threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedRawThreadInfo,
) {
return threadMembersWithoutAddedAshoat(threadInfo).length > 2;
}
@@ -245,7 +262,7 @@
}
function getSingleOtherUser(
- threadInfo: ThreadInfo | RawThreadInfo,
+ threadInfo: ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo,
viewerID: ?string,
): ?string {
if (!viewerID) {
@@ -981,8 +998,8 @@
};
function memberIsAdmin(
- memberInfo: RelativeMemberInfo | MemberInfo,
- threadInfo: ThreadInfo | RawThreadInfo,
+ memberInfo: RelativeMemberInfo | MemberInfo | MinimallyEncodedMemberInfo,
+ threadInfo: ThreadInfo | RawThreadInfo | MinimallyEncodedRawThreadInfo,
): boolean {
return !!(
memberInfo.role && roleIsAdminRole(threadInfo.roles[memberInfo.role])
@@ -997,12 +1014,19 @@
return !!memberInfo.permissions[threadPermissions.CHANGE_ROLE]?.value;
}
-function roleIsAdminRole(roleInfo: ?RoleInfo): boolean {
+function roleIsAdminRole(
+ roleInfo: ?RoleInfo | ?MinimallyEncodedRoleInfo,
+): boolean {
return !!(roleInfo && !roleInfo.isDefault && roleInfo.name === 'Admins');
}
function threadHasAdminRole(
- threadInfo: ?(RawThreadInfo | ThreadInfo | ServerThreadInfo),
+ threadInfo: ?(
+ | RawThreadInfo
+ | ThreadInfo
+ | ServerThreadInfo
+ | MinimallyEncodedRawThreadInfo
+ ),
): boolean {
if (!threadInfo) {
return false;
@@ -1318,7 +1342,11 @@
}
function getContainingThreadID(
- parentThreadInfo: ?ServerThreadInfo | RawThreadInfo | ThreadInfo,
+ parentThreadInfo:
+ | ?ServerThreadInfo
+ | RawThreadInfo
+ | ThreadInfo
+ | MinimallyEncodedRawThreadInfo,
threadType: ThreadType,
): ?string {
if (!parentThreadInfo) {
@@ -1334,7 +1362,11 @@
}
function getCommunity(
- parentThreadInfo: ?ServerThreadInfo | RawThreadInfo | ThreadInfo,
+ parentThreadInfo:
+ | ?ServerThreadInfo
+ | RawThreadInfo
+ | ThreadInfo
+ | MinimallyEncodedRawThreadInfo,
): ?string {
if (!parentThreadInfo) {
return null;
@@ -1549,7 +1581,7 @@
}
function threadInfoInsideCommunity(
- threadInfo: RawThreadInfo | ThreadInfo,
+ threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedRawThreadInfo,
communityID: string,
): boolean {
return threadInfo.community === communityID || threadInfo.id === communityID;
@@ -1625,14 +1657,16 @@
}, [threadInfo]);
}
-function communityOrThreadNoun(threadInfo: RawThreadInfo | ThreadInfo): string {
+function communityOrThreadNoun(
+ threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedRawThreadInfo,
+): string {
return threadTypeIsCommunityRoot(threadInfo.type)
? 'community'
: threadNoun(threadInfo.type, threadInfo.parentThreadID);
}
function getThreadsToDeleteText(
- threadInfo: RawThreadInfo | ThreadInfo,
+ threadInfo: RawThreadInfo | ThreadInfo | MinimallyEncodedRawThreadInfo,
): string {
return `${
threadTypeIsCommunityRoot(threadInfo.type)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 2:58 PM (10 h, 44 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2699409
Default Alt Text
D9811.id33101.diff (7 KB)
Attached To
Mode
D9811: [lib] Update signatures of thread utils to handle `MinimallyEncodedRawThreadInfo`
Attached
Detach File
Event Timeline
Log In to Comment