diff --git a/lib/shared/thread-actions-utils.js b/lib/shared/thread-actions-utils.js
--- a/lib/shared/thread-actions-utils.js
+++ b/lib/shared/thread-actions-utils.js
@@ -2,11 +2,9 @@
import invariant from 'invariant';
-import {
- threadIsPending,
- threadOtherMembers,
- pendingThreadType,
-} from './thread-utils.js';
+import { threadIsPending, threadOtherMembers } from './thread-utils.js';
+import { dmThreadProtocol } from './threads/protocols/dm-thread-protocol.js';
+import { keyserverThreadProtocol } from './threads/protocols/keyserver-thread-protocol.js';
import {
newThreadActionTypes,
removeUsersFromThreadActionTypes,
@@ -128,7 +126,7 @@
});
} else if (threadTypeIsThick(threadInfo.type)) {
const type = assertThickThreadType(
- pendingThreadType(otherMemberIDs.length, 'thick'),
+ dmThreadProtocol.pendingThreadType(otherMemberIDs.length),
);
invariant(
@@ -144,7 +142,7 @@
newThreadType = type;
} else {
const type = assertThinThreadType(
- pendingThreadType(otherMemberIDs.length, 'thin'),
+ keyserverThreadProtocol.pendingThreadType(otherMemberIDs.length),
);
invariant(
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
@@ -12,6 +12,8 @@
import { extractUserMentionsFromText } from './mention-utils.js';
import { relationshipBlockedInEitherDirection } from './relationship-utils.js';
import type { SidebarItem } from './sidebar-item-utils.js';
+import { dmThreadProtocol } from './threads/protocols/dm-thread-protocol.js';
+import { keyserverThreadProtocol } from './threads/protocols/keyserver-thread-protocol.js';
import { protocols } from './threads/protocols/thread-protocols.js';
import {
threadSpecs,
@@ -611,29 +613,6 @@
return [...mentionedMembersOfParent.values()];
}
-function pendingThreadType(
- numberOfOtherMembers: number,
- thickOrThin: 'thick' | 'thin',
-): 4 | 6 | 7 | 13 | 14 | 15 {
- if (thickOrThin === 'thick') {
- if (numberOfOtherMembers === 0) {
- return threadTypes.PRIVATE;
- } else if (numberOfOtherMembers === 1) {
- return threadTypes.PERSONAL;
- } else {
- return threadTypes.LOCAL;
- }
- } else {
- if (numberOfOtherMembers === 0) {
- return threadTypes.GENESIS_PRIVATE;
- } else if (numberOfOtherMembers === 1) {
- return threadTypes.GENESIS_PERSONAL;
- } else {
- return threadTypes.COMMUNITY_SECRET_SUBTHREAD;
- }
- }
-}
-
function threadTypeCanBePending(threadType: ThreadType): boolean {
return (
threadType === threadTypes.GENESIS_PERSONAL ||
@@ -1178,7 +1157,7 @@
let pendingThreadID;
if (searching) {
pendingThreadID = getPendingThreadID(
- pendingThreadType(userInfoInputArray.length, 'thick'),
+ dmThreadProtocol.pendingThreadType(userInfoInputArray.length),
[...userInfoInputArray.map(user => user.id), viewerID],
sourceMessageID,
);
@@ -1198,12 +1177,12 @@
return baseThreadInfo;
}
+ const protocol = params.allUsersSupportThickThreads
+ ? dmThreadProtocol
+ : keyserverThreadProtocol;
return createPendingThread({
viewerID,
- threadType: pendingThreadType(
- userInfoInputArray.length,
- params.allUsersSupportThickThreads ? 'thick' : 'thin',
- ),
+ threadType: protocol.pendingThreadType(userInfoInputArray.length),
members: [
{ ...loggedInUserInfo, isViewer: true },
...userInfoInputArray,
@@ -1794,7 +1773,6 @@
parsePendingThreadID,
createPendingThread,
extractNewMentionedParentMembers,
- pendingThreadType,
filterOutDisabledPermissions,
useThreadFrozenDueToViewerBlock,
rawThreadInfoFromServerThreadInfo,
diff --git a/lib/shared/threads/protocols/dm-thread-protocol.js b/lib/shared/threads/protocols/dm-thread-protocol.js
--- a/lib/shared/threads/protocols/dm-thread-protocol.js
+++ b/lib/shared/threads/protocols/dm-thread-protocol.js
@@ -32,6 +32,7 @@
import {
assertThickThreadType,
thickThreadTypes,
+ threadTypes,
} from '../../../types/thread-types-enum.js';
import type {
ChangeThreadSettingsPayload,
@@ -731,6 +732,16 @@
canBeFrozen: () => true,
+ pendingThreadType: (numberOfOtherMembers: number) => {
+ if (numberOfOtherMembers === 0) {
+ return threadTypes.PRIVATE;
+ } else if (numberOfOtherMembers === 1) {
+ return threadTypes.PERSONAL;
+ } else {
+ return threadTypes.LOCAL;
+ }
+ },
+
allowsDeletingSidebarSource: false,
presentationDetails: {
diff --git a/lib/shared/threads/protocols/keyserver-thread-protocol.js b/lib/shared/threads/protocols/keyserver-thread-protocol.js
--- a/lib/shared/threads/protocols/keyserver-thread-protocol.js
+++ b/lib/shared/threads/protocols/keyserver-thread-protocol.js
@@ -53,6 +53,7 @@
import {
assertThinThreadType,
thinThreadTypes,
+ threadTypes,
} from '../../../types/thread-types-enum.js';
import type { ClientDBThreadInfo } from '../../../types/thread-types.js';
import {
@@ -514,6 +515,16 @@
return thread.id !== genesis().id;
},
+ pendingThreadType: (numberOfOtherMembers: number) => {
+ if (numberOfOtherMembers === 0) {
+ return threadTypes.GENESIS_PRIVATE;
+ } else if (numberOfOtherMembers === 1) {
+ return threadTypes.GENESIS_PERSONAL;
+ } else {
+ return threadTypes.COMMUNITY_SECRET_SUBTHREAD;
+ }
+ },
+
allowsDeletingSidebarSource: true,
presentationDetails: {
diff --git a/lib/shared/threads/thread-spec.js b/lib/shared/threads/thread-spec.js
--- a/lib/shared/threads/thread-spec.js
+++ b/lib/shared/threads/thread-spec.js
@@ -314,6 +314,7 @@
// "Freezing" a thread can occur when a user blocks another user, and those
// two users are the only members of a given chat.
+canBeFrozen: (thread: ThreadInfo) => boolean,
+ +pendingThreadType: (numberOfOtherMembers: number) => ThreadType,
+allowsDeletingSidebarSource: boolean,
+presentationDetails: {
+membershipChangesShownInThreadPreview: boolean,
diff --git a/native/chat/message-list-container.react.js b/native/chat/message-list-container.react.js
--- a/native/chat/message-list-container.react.js
+++ b/native/chat/message-list-container.react.js
@@ -14,10 +14,9 @@
usePotentialMemberItems,
useSearchUsers,
} from 'lib/shared/search-utils.js';
-import {
- pendingThreadType,
- useExistingThreadInfoFinder,
-} from 'lib/shared/thread-utils.js';
+import { useExistingThreadInfoFinder } from 'lib/shared/thread-utils.js';
+import { dmThreadProtocol } from 'lib/shared/threads/protocols/dm-thread-protocol.js';
+import { keyserverThreadProtocol } from 'lib/shared/threads/protocols/keyserver-thread-protocol.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import { threadTypeIsThick } from 'lib/types/thread-types-enum.js';
import type { AccountUserInfo, UserListItem } from 'lib/types/user-types.js';
@@ -166,9 +165,8 @@
if (threadTypeIsThick(threadInfo.type)) {
parentThreadHeader = (
);
@@ -178,9 +176,8 @@
parentThreadHeader = (
);