Page MenuHomePhorge

D14903.1765115801.diff
No OneTemporary

Size
38 KB
Referenced Files
None
Subscribers
None

D14903.1765115801.diff

diff --git a/lib/actions/activity-actions.js b/lib/actions/activity-actions.js
--- a/lib/actions/activity-actions.js
+++ b/lib/actions/activity-actions.js
@@ -119,7 +119,7 @@
return React.useCallback(
async (input: UseSetThreadUnreadStatusInput) =>
- threadSpecs[input.threadInfo.type].protocol.setThreadUnreadStatus(
+ threadSpecs[input.threadInfo.type].protocol().setThreadUnreadStatus(
{ input, viewerID },
{
processAndSendDMOperation,
diff --git a/lib/actions/entry-actions.js b/lib/actions/entry-actions.js
--- a/lib/actions/entry-actions.js
+++ b/lib/actions/entry-actions.js
@@ -200,10 +200,12 @@
return React.useCallback(
(input: UseCreateEntryInput) =>
- threadSpecs[input.threadInfo.type].protocol.createCalendarEntry(
- { input, viewerID },
- { processAndSendDMOperation, keyserverCreateEntry: keyserverCall },
- ),
+ threadSpecs[input.threadInfo.type]
+ .protocol()
+ .createCalendarEntry(
+ { input, viewerID },
+ { processAndSendDMOperation, keyserverCreateEntry: keyserverCall },
+ ),
[keyserverCall, processAndSendDMOperation, viewerID],
);
}
@@ -256,7 +258,7 @@
return React.useCallback(
(input: UseSaveEntryInput) =>
- threadSpecs[input.threadInfo.type].protocol.editCalendarEntry(
+ threadSpecs[input.threadInfo.type].protocol().editCalendarEntry(
{
input,
viewerID,
@@ -316,7 +318,7 @@
return React.useCallback(
(input: UseDeleteEntryInput) =>
- threadSpecs[input.threadInfo.type].protocol.deleteCalendarEntry(
+ threadSpecs[input.threadInfo.type].protocol().deleteCalendarEntry(
{
input,
viewerID,
diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -1359,7 +1359,7 @@
return React.useCallback(
async (input: UseUpdateSubscriptionInput) =>
- threadSpecs[input.threadInfo.type].protocol.updateSubscription(
+ threadSpecs[input.threadInfo.type].protocol().updateSubscription(
{ input, viewerID },
{
processAndSendDMOperation,
diff --git a/lib/handlers/dm-activity-handler.js b/lib/handlers/dm-activity-handler.js
--- a/lib/handlers/dm-activity-handler.js
+++ b/lib/handlers/dm-activity-handler.js
@@ -107,7 +107,7 @@
!viewerID ||
!activeThread ||
!activeThreadInfo ||
- !threadSpecs[activeThreadInfo.type].protocol
+ !threadSpecs[activeThreadInfo.type].protocol()
.threadActivityUpdatedByDMActivityHandler ||
threadIsPending(activeThread)
) {
diff --git a/lib/hooks/input-state-container-hooks.js b/lib/hooks/input-state-container-hooks.js
--- a/lib/hooks/input-state-container-hooks.js
+++ b/lib/hooks/input-state-container-hooks.js
@@ -40,7 +40,7 @@
parentThreadInfo: ?ThreadInfo,
sidebarCreation: boolean,
) =>
- threadSpecs[threadInfo.type].protocol.sendTextMessage(
+ threadSpecs[threadInfo.type].protocol().sendTextMessage(
{
messageInfo,
threadInfo,
@@ -78,7 +78,7 @@
isLegacy: boolean,
) => {
const threadInfo = threadInfos[messageInfo.threadID];
- return threadSpecs[threadInfo.type].protocol.sendMultimediaMessage(
+ return threadSpecs[threadInfo.type].protocol().sendMultimediaMessage(
{
messageInfo,
sidebarCreation,
diff --git a/lib/hooks/thread-hooks.js b/lib/hooks/thread-hooks.js
--- a/lib/hooks/thread-hooks.js
+++ b/lib/hooks/thread-hooks.js
@@ -232,7 +232,7 @@
return React.useCallback(
async (input: UseChangeThreadSettingsInput) =>
- threadSpecs[input.threadInfo.type].protocol.changeThreadSettings(
+ threadSpecs[input.threadInfo.type].protocol().changeThreadSettings(
{ input, viewerID },
{
processAndSendDMOperation,
@@ -395,7 +395,7 @@
const keyserverCall = useJoinKeyserverThread();
return React.useCallback(
async (input: UseJoinThreadInput) =>
- threadSpecs[input.rawThreadInfo.type].protocol.joinThread(
+ threadSpecs[input.rawThreadInfo.type].protocol().joinThread(
{
rawThreadInfo: input.rawThreadInfo,
viewerID,
@@ -453,7 +453,7 @@
return React.useCallback(
(input: UseLeaveThreadInput) =>
- threadSpecs[input.threadInfo.type].protocol.leaveThread(
+ threadSpecs[input.threadInfo.type].protocol().leaveThread(
{ threadInfo: input.threadInfo, viewerID },
{
processAndSendDMOperation,
diff --git a/lib/permissions/thread-permissions.js b/lib/permissions/thread-permissions.js
--- a/lib/permissions/thread-permissions.js
+++ b/lib/permissions/thread-permissions.js
@@ -194,7 +194,7 @@
}
function getRolePermissionBlobs(threadType: ThreadType): RolePermissionBlobs {
- return threadSpecs[threadType].protocol.getRolePermissionBlobs(threadType);
+ return threadSpecs[threadType].protocol().getRolePermissionBlobs(threadType);
}
export {
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -153,7 +153,7 @@
threadHasPermission(threadInfo, threadPermissions.VISIBLE) &&
(threadInChatList(threadInfo) ||
watchedIDs.includes(threadID) ||
- !threadSpecs[threadInfo.type].protocol.messagesStoredOnServer))
+ !threadSpecs[threadInfo.type].protocol().messagesStoredOnServer))
);
}
@@ -629,7 +629,7 @@
threadType = threadIDParseResult?.threadType;
}
const messagesStoredOnServer = threadType
- ? threadSpecs[threadType].protocol.messagesStoredOnServer
+ ? threadSpecs[threadType].protocol().messagesStoredOnServer
: false;
return [
threadID,
@@ -1373,7 +1373,7 @@
const threadType = newThreadInfos[threadID]?.type;
if (
threadType &&
- threadSpecs[threadType].protocol.messagesStoredOnServer
+ threadSpecs[threadType].protocol().messagesStoredOnServer
) {
dbMessageIDsToPrune.push(...removed);
}
diff --git a/lib/selectors/thread-selectors.js b/lib/selectors/thread-selectors.js
--- a/lib/selectors/thread-selectors.js
+++ b/lib/selectors/thread-selectors.js
@@ -457,9 +457,9 @@
const rawThreadInfo = rawThreadInfos[threadID];
if (
threadIsPending(threadID) ||
- !threadSpecs[
- rawThreadInfo.type
- ].protocol.couldBeCreatedFromPendingThread(rawThreadInfo)
+ !threadSpecs[rawThreadInfo.type]
+ .protocol()
+ .couldBeCreatedFromPendingThread(rawThreadInfo)
) {
continue;
}
diff --git a/lib/shared/ancestor-threads.js b/lib/shared/ancestor-threads.js
--- a/lib/shared/ancestor-threads.js
+++ b/lib/shared/ancestor-threads.js
@@ -28,7 +28,7 @@
: ancestorThreads;
}
if (
- threadSpecs[threadInfo.type].protocol
+ threadSpecs[threadInfo.type].protocol()
.arePendingThreadsDescendantsOfGenesis
) {
if (genesisThreadInfo) {
diff --git a/lib/shared/edit-messages-utils.js b/lib/shared/edit-messages-utils.js
--- a/lib/shared/edit-messages-utils.js
+++ b/lib/shared/edit-messages-utils.js
@@ -28,7 +28,7 @@
return React.useCallback(
(messageID, newText) =>
- threadSpecs[threadInfo.type].protocol.editTextMessage(
+ threadSpecs[threadInfo.type].protocol().editTextMessage(
{ threadInfo, messageID, newText, viewerID },
{
keyserverEditMessage: callEditMessage,
diff --git a/lib/shared/message-utils.js b/lib/shared/message-utils.js
--- a/lib/shared/message-utils.js
+++ b/lib/shared/message-utils.js
@@ -618,7 +618,7 @@
async (options?: ?FetchMessagesOptions) => {
const numMessagesToFetch = options?.numMessagesToFetch;
- await threadSpecs[threadInfo.type].protocol.fetchMessages(
+ await threadSpecs[threadInfo.type].protocol().fetchMessages(
{
numMessagesToFetch,
threadID,
diff --git a/lib/shared/messages/add-members-message-spec.js b/lib/shared/messages/add-members-message-spec.js
--- a/lib/shared/messages/add-members-message-spec.js
+++ b/lib/shared/messages/add-members-message-spec.js
@@ -233,14 +233,14 @@
messageInfo: AddMembersMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview,
getLastUpdatedTime: (
rawMessageInfo: RawAddMembersMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview
? rawMessageInfo.time
: null,
diff --git a/lib/shared/messages/join-thread-message-spec.js b/lib/shared/messages/join-thread-message-spec.js
--- a/lib/shared/messages/join-thread-message-spec.js
+++ b/lib/shared/messages/join-thread-message-spec.js
@@ -179,14 +179,14 @@
messageInfo: JoinThreadMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview,
getLastUpdatedTime: (
rawMessageInfo: RawJoinThreadMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview
? rawMessageInfo.time
: null,
diff --git a/lib/shared/messages/leave-thread-message-spec.js b/lib/shared/messages/leave-thread-message-spec.js
--- a/lib/shared/messages/leave-thread-message-spec.js
+++ b/lib/shared/messages/leave-thread-message-spec.js
@@ -179,14 +179,14 @@
messageInfo: LeaveThreadMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview,
getLastUpdatedTime: (
rawMessageInfo: RawLeaveThreadMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview
? rawMessageInfo.time
: null,
diff --git a/lib/shared/messages/remove-members-message-spec.js b/lib/shared/messages/remove-members-message-spec.js
--- a/lib/shared/messages/remove-members-message-spec.js
+++ b/lib/shared/messages/remove-members-message-spec.js
@@ -239,14 +239,14 @@
messageInfo: RemoveMembersMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview,
getLastUpdatedTime: (
rawMessageInfo: RawRemoveMembersMessageInfo,
params: ShowInMessagePreviewParams,
) =>
- threadSpecs[params.threadInfo.type].protocol.presentationDetails
+ threadSpecs[params.threadInfo.type].protocol().presentationDetails
.membershipChangesShownInThreadPreview
? rawMessageInfo.time
: null,
diff --git a/lib/shared/messages/text-message-spec.js b/lib/shared/messages/text-message-spec.js
--- a/lib/shared/messages/text-message-spec.js
+++ b/lib/shared/messages/text-message-spec.js
@@ -316,7 +316,7 @@
const newMemberIDs = mentionedNewMembers.map(({ id }) => id);
- await threadSpecs[threadInfo.type].protocol.addThreadMembers(
+ await threadSpecs[threadInfo.type].protocol().addThreadMembers(
{ newMemberIDs, threadInfo },
{
dmAddThreadMembers: callAddDMThreadMembers,
diff --git a/lib/shared/reaction-utils.js b/lib/shared/reaction-utils.js
--- a/lib/shared/reaction-utils.js
+++ b/lib/shared/reaction-utils.js
@@ -98,7 +98,8 @@
if (
!targetMessageInfo ||
(!targetMessageInfo.id &&
- !threadSpecs[threadInfo.type].protocol.canActionsTargetPendingMessages) ||
+ !threadSpecs[threadInfo.type].protocol()
+ .canActionsTargetPendingMessages) ||
(threadInfo.sourceMessageID &&
threadInfo.sourceMessageID === targetMessageInfo.id)
) {
@@ -138,7 +139,7 @@
: false;
const action = viewerReacted ? 'remove_reaction' : 'add_reaction';
- void threadSpecs[threadInfo.type].protocol.sendReaction(
+ void threadSpecs[threadInfo.type].protocol().sendReaction(
{
messageID,
threadInfo,
diff --git a/lib/shared/search-utils.js b/lib/shared/search-utils.js
--- a/lib/shared/search-utils.js
+++ b/lib/shared/search-utils.js
@@ -158,7 +158,7 @@
}
return !!(
threadType &&
- threadSpecs[threadType].protocol.presentationDetails
+ threadSpecs[threadType].protocol().presentationDetails
.usersWithoutDeviceListExcludedFromSearchResult &&
!userHasDeviceList(userID, auxUserInfos)
);
diff --git a/lib/shared/sidebar-utils.js b/lib/shared/sidebar-utils.js
--- a/lib/shared/sidebar-utils.js
+++ b/lib/shared/sidebar-utils.js
@@ -105,7 +105,7 @@
return createPendingThread({
viewerID,
threadType:
- threadSpecs[parentThreadInfo.type].protocol.sidebarConfig
+ threadSpecs[parentThreadInfo.type].protocol().sidebarConfig
.sidebarThreadType,
members: [...initialMembers.values()],
parentThreadInfo,
@@ -214,7 +214,8 @@
if (
!messageInfo ||
(!messageInfo.id &&
- !threadSpecs[threadInfo.type].protocol.canActionsTargetPendingMessages) ||
+ !threadSpecs[threadInfo.type].protocol()
+ .canActionsTargetPendingMessages) ||
(threadInfo.sourceMessageID &&
threadInfo.sourceMessageID === messageInfo.id) ||
isInvalidSidebarSource(messageInfo)
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
@@ -179,8 +179,9 @@
return React.useMemo(() => {
return threadInfos.filter((threadInfo: ThreadInfo) => {
- const canBeFrozen =
- threadSpecs[threadInfo.type].protocol.canBeFrozen(threadInfo);
+ const canBeFrozen = threadSpecs[threadInfo.type]
+ .protocol()
+ .canBeFrozen(threadInfo);
if (!canBeFrozen || !loggedInUserInfo) {
return hasPermission(threadInfo.currentUser.permissions, permission);
}
@@ -392,7 +393,7 @@
let pendingThreadKey;
if (sourceMessageID) {
const prefix =
- threadSpecs[threadType].protocol.sidebarConfig.pendingSidebarURLPrefix;
+ threadSpecs[threadType].protocol().sidebarConfig.pendingSidebarURLPrefix;
pendingThreadKey = `${prefix}/${sourceMessageID}`;
} else {
pendingThreadKey = [...memberIDs].sort().join('+');
@@ -481,7 +482,7 @@
specialRole: specialRoles.DEFAULT_ROLE,
};
- const rawThreadInfo = threadSpecs[threadType].protocol.createPendingThread({
+ const rawThreadInfo = threadSpecs[threadType].protocol().createPendingThread({
createPendingThreadArgs: args,
creationTime: now,
membershipPermissions,
@@ -1463,7 +1464,8 @@
}
members.push(...mentionedNewMembers);
const threadType =
- threadSpecs[parentThreadInfo.type].protocol.sidebarConfig.sidebarThreadType;
+ threadSpecs[parentThreadInfo.type].protocol().sidebarConfig
+ .sidebarThreadType;
return createPendingThread({
viewerID,
diff --git a/lib/shared/threads/community-announcement-root-spec.js b/lib/shared/threads/community-announcement-root-spec.js
--- a/lib/shared/threads/community-announcement-root-spec.js
+++ b/lib/shared/threads/community-announcement-root-spec.js
@@ -7,7 +7,7 @@
const communityAnnouncementRootSpec: ThreadSpec<MemberInfoSansPermissions> =
Object.freeze({
traits: new Set(['community', 'announcement']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Community',
});
diff --git a/lib/shared/threads/community-open-announcement-subthread-spec.js b/lib/shared/threads/community-open-announcement-subthread-spec.js
--- a/lib/shared/threads/community-open-announcement-subthread-spec.js
+++ b/lib/shared/threads/community-open-announcement-subthread-spec.js
@@ -7,7 +7,7 @@
const communityOpenAnnouncementSubthreadSpec: ThreadSpec<MemberInfoSansPermissions> =
Object.freeze({
traits: new Set(['communitySubthread', 'announcement']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Open',
});
diff --git a/lib/shared/threads/community-open-subthread-spec.js b/lib/shared/threads/community-open-subthread-spec.js
--- a/lib/shared/threads/community-open-subthread-spec.js
+++ b/lib/shared/threads/community-open-subthread-spec.js
@@ -7,7 +7,7 @@
const communityOpenSubthreadSpec: ThreadSpec<MemberInfoSansPermissions> =
Object.freeze({
traits: new Set(['communitySubthread']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Open',
});
diff --git a/lib/shared/threads/community-root-spec.js b/lib/shared/threads/community-root-spec.js
--- a/lib/shared/threads/community-root-spec.js
+++ b/lib/shared/threads/community-root-spec.js
@@ -6,7 +6,7 @@
const communityRootSpec: ThreadSpec<MemberInfoSansPermissions> = Object.freeze({
traits: new Set(['community']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Community',
});
diff --git a/lib/shared/threads/community-secret-announcement-subthread-spec.js b/lib/shared/threads/community-secret-announcement-subthread-spec.js
--- a/lib/shared/threads/community-secret-announcement-subthread-spec.js
+++ b/lib/shared/threads/community-secret-announcement-subthread-spec.js
@@ -7,7 +7,7 @@
const communitySecretAnnouncementSubthreadSpec: ThreadSpec<MemberInfoSansPermissions> =
Object.freeze({
traits: new Set(['communitySubthread', 'announcement']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Secret',
});
diff --git a/lib/shared/threads/community-secret-subthread-spec.js b/lib/shared/threads/community-secret-subthread-spec.js
--- a/lib/shared/threads/community-secret-subthread-spec.js
+++ b/lib/shared/threads/community-secret-subthread-spec.js
@@ -7,7 +7,7 @@
const communitySecretSubthreadSpec: ThreadSpec<MemberInfoSansPermissions> =
Object.freeze({
traits: new Set(['communitySubthread']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Secret',
});
diff --git a/lib/shared/threads/genesis-personal-spec.js b/lib/shared/threads/genesis-personal-spec.js
--- a/lib/shared/threads/genesis-personal-spec.js
+++ b/lib/shared/threads/genesis-personal-spec.js
@@ -7,7 +7,7 @@
const genesisPersonalSpec: ThreadSpec<MemberInfoSansPermissions> =
Object.freeze({
traits: new Set(['personal']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Personal',
});
diff --git a/lib/shared/threads/genesis-private-spec.js b/lib/shared/threads/genesis-private-spec.js
--- a/lib/shared/threads/genesis-private-spec.js
+++ b/lib/shared/threads/genesis-private-spec.js
@@ -7,7 +7,7 @@
const genesisPrivateSpec: ThreadSpec<MemberInfoSansPermissions> = Object.freeze(
{
traits: new Set(['private']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Private',
},
);
diff --git a/lib/shared/threads/genesis-spec.js b/lib/shared/threads/genesis-spec.js
--- a/lib/shared/threads/genesis-spec.js
+++ b/lib/shared/threads/genesis-spec.js
@@ -6,7 +6,7 @@
const genesisSpec: ThreadSpec<MemberInfoSansPermissions> = Object.freeze({
traits: new Set(['community', 'announcement']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Community',
});
diff --git a/lib/shared/threads/local-spec.js b/lib/shared/threads/local-spec.js
--- a/lib/shared/threads/local-spec.js
+++ b/lib/shared/threads/local-spec.js
@@ -6,7 +6,7 @@
const localSpec: ThreadSpec<MinimallyEncodedThickMemberInfo> = Object.freeze({
traits: new Set(),
- protocol: dmThreadProtocol,
+ protocol: () => dmThreadProtocol,
threadLabel: 'Local DM',
});
diff --git a/lib/shared/threads/personal-spec.js b/lib/shared/threads/personal-spec.js
--- a/lib/shared/threads/personal-spec.js
+++ b/lib/shared/threads/personal-spec.js
@@ -7,7 +7,7 @@
const personalSpec: ThreadSpec<MinimallyEncodedThickMemberInfo> = Object.freeze(
{
traits: new Set(['personal']),
- protocol: dmThreadProtocol,
+ protocol: () => dmThreadProtocol,
threadLabel: 'Local DM',
},
);
diff --git a/lib/shared/threads/private-spec.js b/lib/shared/threads/private-spec.js
--- a/lib/shared/threads/private-spec.js
+++ b/lib/shared/threads/private-spec.js
@@ -6,7 +6,7 @@
const privateSpec: ThreadSpec<MinimallyEncodedThickMemberInfo> = Object.freeze({
traits: new Set(['private']),
- protocol: dmThreadProtocol,
+ protocol: () => dmThreadProtocol,
threadLabel: 'Local DM',
});
diff --git a/lib/shared/threads/protocols/thread-protocols.js b/lib/shared/threads/protocols/thread-protocols.js
--- a/lib/shared/threads/protocols/thread-protocols.js
+++ b/lib/shared/threads/protocols/thread-protocols.js
@@ -21,7 +21,7 @@
threadInfo: ?(LegacyRawThreadInfo | RawThreadInfo),
): boolean {
if (threadInfo) {
- return threadSpecs[threadInfo.type].protocol.dataIsBackedUp;
+ return threadSpecs[threadInfo.type].protocol().dataIsBackedUp;
}
return !!getProtocolByThreadID(threadID)?.dataIsBackedUp;
}
diff --git a/lib/shared/threads/sidebar-spec.js b/lib/shared/threads/sidebar-spec.js
--- a/lib/shared/threads/sidebar-spec.js
+++ b/lib/shared/threads/sidebar-spec.js
@@ -6,7 +6,7 @@
const sidebarSpec: ThreadSpec<MemberInfoSansPermissions> = Object.freeze({
traits: new Set(['sidebar']),
- protocol: keyserverThreadProtocol,
+ protocol: () => keyserverThreadProtocol,
threadLabel: 'Thread',
});
diff --git a/lib/shared/threads/thick-sidebar-spec.js b/lib/shared/threads/thick-sidebar-spec.js
--- a/lib/shared/threads/thick-sidebar-spec.js
+++ b/lib/shared/threads/thick-sidebar-spec.js
@@ -7,7 +7,7 @@
const thickSidebarSpec: ThreadSpec<MinimallyEncodedThickMemberInfo> =
Object.freeze({
traits: new Set(['sidebar']),
- protocol: dmThreadProtocol,
+ protocol: () => dmThreadProtocol,
threadLabel: 'Thread',
});
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
@@ -414,6 +414,6 @@
| MinimallyEncodedThickMemberInfo,
> = {
+traits: $ReadOnlySet<ThreadTrait>,
- +protocol: ThreadProtocol<RawThreadMemberType>,
+ +protocol: () => ThreadProtocol<RawThreadMemberType>,
+threadLabel: string,
};
diff --git a/lib/utils/delete-message-utils.js b/lib/utils/delete-message-utils.js
--- a/lib/utils/delete-message-utils.js
+++ b/lib/utils/delete-message-utils.js
@@ -30,7 +30,7 @@
const messageID = message.id;
invariant(messageID, 'Message ID should be set');
const threadInfo = threadInfos[message.threadID];
- await threadSpecs[threadInfo.type].protocol.deleteMessage(
+ await threadSpecs[threadInfo.type].protocol().deleteMessage(
{ messageID, viewerID, threadInfo },
{
keyserverDeleteMessage: callDeleteMessage,
@@ -77,7 +77,7 @@
}
if (
- !threadSpecs[threadInfo.type].protocol.allowsDeletingSidebarSource &&
+ !threadSpecs[threadInfo.type].protocol().allowsDeletingSidebarSource &&
(targetMessageInfo.time < threadInfo.creationTime ||
threadCreatedFromMessage)
) {
diff --git a/lib/utils/thread-ops-utils.js b/lib/utils/thread-ops-utils.js
--- a/lib/utils/thread-ops-utils.js
+++ b/lib/utils/thread-ops-utils.js
@@ -95,12 +95,14 @@
const threadType = assertThreadType(clientDBThreadInfo.type);
- return threadSpecs[threadType].protocol.convertClientDBThreadInfo(
- clientDBThreadInfo,
- minimallyEncodedMembers,
- minimallyEncodedRoles,
- minimallyEncodedCurrentUser,
- );
+ return threadSpecs[threadType]
+ .protocol()
+ .convertClientDBThreadInfo(
+ clientDBThreadInfo,
+ minimallyEncodedMembers,
+ minimallyEncodedRoles,
+ minimallyEncodedCurrentUser,
+ );
}
// WARNING: Do not consume or delete this function!
diff --git a/native/avatars/avatar-hooks.js b/native/avatars/avatar-hooks.js
--- a/native/avatars/avatar-hooks.js
+++ b/native/avatars/avatar-hooks.js
@@ -400,7 +400,7 @@
selection: NativeMediaSelection,
threadInfo: ThreadInfo | RawThreadInfo,
): Promise<void> => {
- const metadataUploadLocation = threadSpecs[threadInfo.type].protocol
+ const metadataUploadLocation = threadSpecs[threadInfo.type].protocol()
.uploadMultimediaMetadataToKeyserver
? 'keyserver'
: 'none';
diff --git a/native/calendar/entry.react.js b/native/calendar/entry.react.js
--- a/native/calendar/entry.react.js
+++ b/native/calendar/entry.react.js
@@ -842,10 +842,9 @@
return connectionSelector(keyserverID)(state)?.status === 'connected';
});
- const online = threadSpecs[threadInfo.type].protocol.calendarIsOnline(
- socketState,
- isKeyserverConnected,
- );
+ const online = threadSpecs[threadInfo.type]
+ .protocol()
+ .calendarIsOnline(socketState, isKeyserverConnected);
const canEditEntry = useThreadHasPermission(
threadInfo,
diff --git a/native/chat/chat-thread-list-item.react.js b/native/chat/chat-thread-list-item.react.js
--- a/native/chat/chat-thread-list-item.react.js
+++ b/native/chat/chat-thread-list-item.react.js
@@ -136,7 +136,7 @@
? styles.iconUnread
: styles.iconRead;
const iconName =
- threadSpecs[data.threadInfo.type].protocol.presentationDetails
+ threadSpecs[data.threadInfo.type].protocol().presentationDetails
.nativeChatThreadListIcon;
const threadDetails = React.useMemo(
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
@@ -160,7 +160,7 @@
if (searching) {
const { userInfoInputArray, genesisThreadInfo } = this.props;
let parentThreadHeader;
- const protocol = threadSpecs[threadInfo.type].protocol;
+ const protocol = threadSpecs[threadInfo.type].protocol();
const childThreadType = protocol.pendingThreadType(
userInfoInputArray.length,
);
diff --git a/native/chat/settings/add-users-modal.react.js b/native/chat/settings/add-users-modal.react.js
--- a/native/chat/settings/add-users-modal.react.js
+++ b/native/chat/settings/add-users-modal.react.js
@@ -85,7 +85,7 @@
}
try {
- await threadSpecs[threadInfo.type].protocol.addThreadMembers(
+ await threadSpecs[threadInfo.type].protocol().addThreadMembers(
{ newMemberIDs: userInfoInputIDs, threadInfo },
{
dmAddThreadMembers: addDMThreadMembers,
diff --git a/native/chat/settings/thread-settings.react.js b/native/chat/settings/thread-settings.react.js
--- a/native/chat/settings/thread-settings.react.js
+++ b/native/chat/settings/thread-settings.react.js
@@ -704,7 +704,7 @@
const limit = 6;
if (
- !threadSpecs[threadInfo.type].protocol.presentationDetails
+ !threadSpecs[threadInfo.type].protocol().presentationDetails
.supportsMediaGallery
) {
return listData;
diff --git a/native/components/thread-ancestors-label.react.js b/native/components/thread-ancestors-label.react.js
--- a/native/components/thread-ancestors-label.react.js
+++ b/native/components/thread-ancestors-label.react.js
@@ -52,10 +52,9 @@
}, [styles.pathText, styles.unread, unread]);
return React.useMemo(() => {
- const label =
- threadSpecs[
- threadInfo.type
- ].protocol.presentationDetails.threadAncestorLabel(ancestorPath);
+ const label = threadSpecs[threadInfo.type]
+ .protocol()
+ .presentationDetails.threadAncestorLabel(ancestorPath);
return (
<Text numberOfLines={1} style={ancestorPathStyle}>
diff --git a/native/input/input-state-container.react.js b/native/input/input-state-container.react.js
--- a/native/input/input-state-container.react.js
+++ b/native/input/input-state-container.react.js
@@ -559,17 +559,17 @@
let threadCreationPromise = this.pendingThreadCreations.get(threadInfo.id);
if (!threadCreationPromise) {
const calendarQuery = this.props.calendarQuery();
- threadCreationPromise = threadSpecs[
- threadInfo.type
- ].protocol.createRealThreadFromPendingThread({
- threadInfo,
- dispatchActionPromise: this.props.dispatchActionPromise,
- createNewThinThread: this.props.newThinThread,
- createNewThickThread: this.props.newThickThread,
- sourceMessageID: threadInfo.sourceMessageID,
- viewerID: this.props.viewerID,
- calendarQuery,
- });
+ threadCreationPromise = threadSpecs[threadInfo.type]
+ .protocol()
+ .createRealThreadFromPendingThread({
+ threadInfo,
+ dispatchActionPromise: this.props.dispatchActionPromise,
+ createNewThinThread: this.props.newThinThread,
+ createNewThickThread: this.props.newThickThread,
+ sourceMessageID: threadInfo.sourceMessageID,
+ viewerID: this.props.viewerID,
+ calendarQuery,
+ });
this.pendingThreadCreations.set(threadInfo.id, threadCreationPromise);
}
return threadCreationPromise;
@@ -841,7 +841,7 @@
'uploaded media should be encrypted',
);
const uploadMetadataToKeyserver =
- threadSpecs[threadInfo.type].protocol
+ threadSpecs[threadInfo.type].protocol()
.uploadMultimediaMetadataToKeyserver;
const uploadPromise = this.props.blobServiceUpload({
uploadInput: {
diff --git a/web/avatars/edit-thread-avatar-menu.react.js b/web/avatars/edit-thread-avatar-menu.react.js
--- a/web/avatars/edit-thread-avatar-menu.react.js
+++ b/web/avatars/edit-thread-avatar-menu.react.js
@@ -73,7 +73,8 @@
const uploadAvatarMedia = useUploadAvatarMedia({
uploadMetadataToKeyserver:
- threadSpecs[threadInfo.type].protocol.uploadMultimediaMetadataToKeyserver,
+ threadSpecs[threadInfo.type].protocol()
+ .uploadMultimediaMetadataToKeyserver,
});
const onImageSelected = React.useCallback(
async (event: SyntheticEvent<HTMLInputElement>) => {
diff --git a/web/calendar/entry.react.js b/web/calendar/entry.react.js
--- a/web/calendar/entry.react.js
+++ b/web/calendar/entry.react.js
@@ -175,7 +175,8 @@
let historyButton = null;
if (
this.props.entryInfo.id &&
- threadSpecs[this.props.threadInfo.type].protocol.supportsCalendarHistory
+ threadSpecs[this.props.threadInfo.type].protocol()
+ .supportsCalendarHistory
) {
historyButton = (
<a href="#" onClick={this.onHistory}>
@@ -509,10 +510,9 @@
return connectionSelector(keyserverID)(state)?.status === 'connected';
});
- const online = threadSpecs[threadInfo.type].protocol.calendarIsOnline(
- socketState,
- isKeyserverConnected,
- );
+ const online = threadSpecs[threadInfo.type]
+ .protocol()
+ .calendarIsOnline(socketState, isKeyserverConnected);
const callCreateEntry = useCreateEntry();
const callSaveEntry = useSaveEntry();
diff --git a/web/chat/chat-thread-list-item.react.js b/web/chat/chat-thread-list-item.react.js
--- a/web/chat/chat-thread-list-item.react.js
+++ b/web/chat/chat-thread-list-item.react.js
@@ -129,7 +129,7 @@
const { uiName } = useResolvedThreadInfo(threadInfo);
const presentationDetails =
- threadSpecs[threadInfo.type].protocol.presentationDetails;
+ threadSpecs[threadInfo.type].protocol().presentationDetails;
const iconClass = unread ? css.iconUnread : css.iconRead;
const icon =
diff --git a/web/chat/thread-menu.react.js b/web/chat/thread-menu.react.js
--- a/web/chat/thread-menu.react.js
+++ b/web/chat/thread-menu.react.js
@@ -99,7 +99,7 @@
const threadMediaGalleryItem = React.useMemo(() => {
if (
- !threadSpecs[threadInfo.type].protocol.presentationDetails
+ !threadSpecs[threadInfo.type].protocol().presentationDetails
.supportsMediaGallery
) {
return null;
diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js
--- a/web/input/input-state-container.react.js
+++ b/web/input/input-state-container.react.js
@@ -581,17 +581,17 @@
let threadCreationPromise = this.pendingThreadCreations.get(threadInfo.id);
if (!threadCreationPromise) {
const calendarQuery = this.props.calendarQuery();
- threadCreationPromise = threadSpecs[
- threadInfo.type
- ].protocol.createRealThreadFromPendingThread({
- threadInfo,
- dispatchActionPromise: this.props.dispatchActionPromise,
- createNewThinThread: this.props.newThinThread,
- createNewThickThread: this.props.newThickThread,
- sourceMessageID: threadInfo.sourceMessageID,
- viewerID: this.props.viewerID,
- calendarQuery,
- });
+ threadCreationPromise = threadSpecs[threadInfo.type]
+ .protocol()
+ .createRealThreadFromPendingThread({
+ threadInfo,
+ dispatchActionPromise: this.props.dispatchActionPromise,
+ createNewThinThread: this.props.newThinThread,
+ createNewThickThread: this.props.newThickThread,
+ sourceMessageID: threadInfo.sourceMessageID,
+ viewerID: this.props.viewerID,
+ calendarQuery,
+ });
this.pendingThreadCreations.set(threadInfo.id, threadCreationPromise);
}
return threadCreationPromise;
@@ -866,7 +866,8 @@
const { selectTime, localID, encryptionKey } = upload;
const threadID = threadInfo.id;
const uploadMultimediaMetadataToKeyserver =
- threadSpecs[threadInfo.type].protocol.uploadMultimediaMetadataToKeyserver;
+ threadSpecs[threadInfo.type].protocol()
+ .uploadMultimediaMetadataToKeyserver;
const isEncrypted =
!!encryptionKey &&
(upload.mediaType === 'encrypted_photo' ||
@@ -1208,7 +1209,7 @@
if (pendingUpload.serverID) {
const { serverID } = pendingUpload;
if (
- threadSpecs[threadInfo.type].protocol
+ threadSpecs[threadInfo.type].protocol()
.uploadMultimediaMetadataToKeyserver
) {
void this.props.deleteUpload({
diff --git a/web/modals/history/history-modal.react.js b/web/modals/history/history-modal.react.js
--- a/web/modals/history/history-modal.react.js
+++ b/web/modals/history/history-modal.react.js
@@ -122,7 +122,7 @@
const threadType = threadInfos?.[entryInfo.threadID].type;
const supportsCalendarHistory =
!threadType ||
- threadSpecs[threadType].protocol.supportsCalendarHistory;
+ threadSpecs[threadType].protocol().supportsCalendarHistory;
return entryInfo.id && supportsCalendarHistory;
}),
_map((entryInfo: EntryInfo) => {
diff --git a/web/modals/threads/members/add-members-modal.react.js b/web/modals/threads/members/add-members-modal.react.js
--- a/web/modals/threads/members/add-members-modal.react.js
+++ b/web/modals/threads/members/add-members-modal.react.js
@@ -66,7 +66,7 @@
const addUsers = React.useCallback(() => {
const newMemberIDs = Array.from(pendingUsersToAdd.keys());
- void threadSpecs[threadInfo.type].protocol.addThreadMembers(
+ void threadSpecs[threadInfo.type].protocol().addThreadMembers(
{ newMemberIDs, threadInfo },
{
dmAddThreadMembers: addDMThreadMembers,
diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js
--- a/web/redux/redux-setup.js
+++ b/web/redux/redux-setup.js
@@ -475,7 +475,7 @@
document.hasFocus() &&
!state.navInfo.pendingThread &&
state.threadStore.threadInfos[activeThread].currentUser.unread &&
- !threadSpecs[state.threadStore.threadInfos[activeThread].type].protocol
+ !threadSpecs[state.threadStore.threadInfos[activeThread].type].protocol()
.threadActivityUpdatedByDMActivityHandler
) {
// Makes sure a currently focused thread is never unread
diff --git a/web/shared-worker/queries/fetch-messages-queries.test.js b/web/shared-worker/queries/fetch-messages-queries.test.js
--- a/web/shared-worker/queries/fetch-messages-queries.test.js
+++ b/web/shared-worker/queries/fetch-messages-queries.test.js
@@ -55,7 +55,7 @@
pinnedCount: 0,
timestamps: null,
},
- threadSpecs[threadType].protocol.dataIsBackedUp,
+ threadSpecs[threadType].protocol().dataIsBackedUp,
);
// Create 50 messages using the appropriate backup flag
@@ -72,7 +72,7 @@
};
queryExecutor.replaceMessage(
message,
- threadSpecs[threadType].protocol.dataIsBackedUp,
+ threadSpecs[threadType].protocol().dataIsBackedUp,
);
}
@@ -97,7 +97,7 @@
pinnedCount: 0,
timestamps: null,
},
- threadSpecs[thickThreadType].protocol.dataIsBackedUp,
+ threadSpecs[thickThreadType].protocol().dataIsBackedUp,
);
// Add 10 messages to the thick thread (which will go to backup tables)
@@ -114,7 +114,7 @@
};
queryExecutor.replaceMessage(
message,
- threadSpecs[thickThreadType].protocol.dataIsBackedUp,
+ threadSpecs[thickThreadType].protocol().dataIsBackedUp,
);
}
});
diff --git a/web/shared-worker/queries/get-initial-messages.test.js b/web/shared-worker/queries/get-initial-messages.test.js
--- a/web/shared-worker/queries/get-initial-messages.test.js
+++ b/web/shared-worker/queries/get-initial-messages.test.js
@@ -57,7 +57,7 @@
pinnedCount: 0,
timestamps: null,
},
- threadSpecs[type].protocol.dataIsBackedUp,
+ threadSpecs[type].protocol().dataIsBackedUp,
);
};
@@ -80,7 +80,7 @@
content,
time: BigInt(time),
},
- threadSpecs[threadType].protocol.dataIsBackedUp,
+ threadSpecs[threadType].protocol().dataIsBackedUp,
);
};
@@ -101,7 +101,7 @@
type,
extras: '{}',
},
- threadSpecs[threadType].protocol.dataIsBackedUp,
+ threadSpecs[threadType].protocol().dataIsBackedUp,
);
};

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 7, 1:56 PM (14 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5844408
Default Alt Text
D14903.1765115801.diff (38 KB)

Event Timeline