Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3372713
D13842.id45509.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D13842.id45509.diff
View Options
diff --git a/lib/shared/dm-ops/add-members-spec.js b/lib/shared/dm-ops/add-members-spec.js
--- a/lib/shared/dm-ops/add-members-spec.js
+++ b/lib/shared/dm-ops/add-members-spec.js
@@ -65,10 +65,6 @@
'thread members but is missing from the store',
);
}
- invariant(
- !parentThreadInfo || parentThreadInfo.thick,
- 'Parent thread should be thick',
- );
const { membershipPermissions } = createRoleAndPermissionForThickThreads(
threadInfo.type,
@@ -103,13 +99,6 @@
const rawMessageInfos = [rawMessageInfo];
const currentThreadInfo = threadInfos[threadID];
- if (!currentThreadInfo.thick) {
- return {
- rawMessageInfos: [],
- updateInfos: [],
- blobOps: [],
- };
- }
const { membershipPermissions, roleID } = createPermissionsForNewMembers(
currentThreadInfo,
diff --git a/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js b/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js
--- a/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js
+++ b/lib/shared/dm-ops/add-viewer-to-thread-members-spec.js
@@ -72,13 +72,6 @@
const threadID = existingThreadDetails.threadID;
const currentThreadInfo = threadInfos[threadID];
- if (currentThreadInfo && !currentThreadInfo.thick) {
- return {
- rawMessageInfos: [],
- updateInfos: [],
- blobOps: [],
- };
- }
const memberTimestamps = {
...currentThreadInfo?.timestamps?.members,
diff --git a/lib/shared/dm-ops/change-thread-read-status-spec.js b/lib/shared/dm-ops/change-thread-read-status-spec.js
--- a/lib/shared/dm-ops/change-thread-read-status-spec.js
+++ b/lib/shared/dm-ops/change-thread-read-status-spec.js
@@ -1,6 +1,5 @@
// @flow
-import invariant from 'invariant';
import uuid from 'uuid';
import type {
@@ -31,7 +30,6 @@
const { threadID, unread, time } = dmOperation;
const threadInfo = utilities.threadInfos[threadID];
- invariant(threadInfo.thick, 'Thread should be thick');
if (threadInfo.timestamps.currentUser.unread > time) {
return {
rawMessageInfos: [],
diff --git a/lib/shared/dm-ops/change-thread-settings-spec.js b/lib/shared/dm-ops/change-thread-settings-spec.js
--- a/lib/shared/dm-ops/change-thread-settings-spec.js
+++ b/lib/shared/dm-ops/change-thread-settings-spec.js
@@ -1,6 +1,5 @@
// @flow
-import invariant from 'invariant';
import uuid from 'uuid';
import type {
@@ -151,7 +150,7 @@
const { time } = dmOperation;
const threadID = getThreadIDFromChangeThreadSettingsDMOp(dmOperation);
- const threadInfo: ?RawThreadInfo = utilities.threadInfos[threadID];
+ const threadInfo = utilities.threadInfos[threadID];
const updateInfos: Array<ClientUpdateInfo> = [];
const { fieldNameToMessageData, threadInfoUpdate } =
@@ -164,7 +163,6 @@
({ rawMessageInfo }) => rawMessageInfo,
);
- invariant(threadInfo?.thick, 'Thread should be thick');
let threadInfoToUpdate: ThickRawThreadInfo = threadInfo;
for (const fieldName in threadInfoUpdate) {
const timestamp = threadInfoToUpdate.timestamps[fieldName];
diff --git a/lib/shared/dm-ops/change-thread-subscription.js b/lib/shared/dm-ops/change-thread-subscription.js
--- a/lib/shared/dm-ops/change-thread-subscription.js
+++ b/lib/shared/dm-ops/change-thread-subscription.js
@@ -24,7 +24,6 @@
const { viewerID, threadInfos } = utilities;
const threadInfo = threadInfos[threadID];
- invariant(threadInfo.thick, 'Thread should be thick');
if (threadInfo.timestamps.members[creatorID].subscription > time) {
return {
diff --git a/lib/shared/dm-ops/create-thread-spec.js b/lib/shared/dm-ops/create-thread-spec.js
--- a/lib/shared/dm-ops/create-thread-spec.js
+++ b/lib/shared/dm-ops/create-thread-spec.js
@@ -1,6 +1,5 @@
// @flow
-import invariant from 'invariant';
import uuid from 'uuid';
import type {
@@ -140,10 +139,6 @@
'thick thread but is missing from the store',
);
}
- invariant(
- !parentThreadInfo || parentThreadInfo.thick,
- 'Parent thread should be thick',
- );
const { membershipPermissions, role } =
createRoleAndPermissionForThickThreads(
diff --git a/lib/shared/dm-ops/dm-op-spec.js b/lib/shared/dm-ops/dm-op-spec.js
--- a/lib/shared/dm-ops/dm-op-spec.js
+++ b/lib/shared/dm-ops/dm-op-spec.js
@@ -7,13 +7,13 @@
import type { UserIdentitiesResponse } from '../../types/identity-service-types.js';
import type { RawMessageInfo } from '../../types/message-types.js';
import type { NotificationsCreationData } from '../../types/notif-types.js';
-import type { RawThreadInfos } from '../../types/thread-types.js';
+import type { ThickRawThreadInfos } from '../../types/thread-types.js';
export type ProcessDMOperationUtilities = {
+viewerID: string,
// Needed to fetch sidebar source messages
+fetchMessage: (messageID: string) => Promise<?RawMessageInfo>,
- +threadInfos: RawThreadInfos,
+ +threadInfos: ThickRawThreadInfos,
+entryInfos: RawEntryInfos,
+findUserIdentities: (
userIDs: $ReadOnlyArray<string>,
diff --git a/lib/shared/dm-ops/dm-op-utils.js b/lib/shared/dm-ops/dm-op-utils.js
--- a/lib/shared/dm-ops/dm-op-utils.js
+++ b/lib/shared/dm-ops/dm-op-utils.js
@@ -17,6 +17,7 @@
import { useGetLatestMessageEdit } from '../../hooks/latest-message-edit.js';
import { useGetAndUpdateDeviceListsForUsers } from '../../hooks/peer-list-hooks.js';
import { mergeUpdatesWithMessageInfos } from '../../reducers/message-reducer.js';
+import { thickRawThreadInfosSelector } from '../../selectors/thread-selectors.js';
import { getAllPeerUserIDAndDeviceIDs } from '../../selectors/user-selectors.js';
import { type P2PMessageRecipient } from '../../tunnelbroker/peer-to-peer-context.js';
import type {
@@ -478,7 +479,7 @@
viewerID: ?string,
}> {
const fetchMessage = useGetLatestMessageEdit();
- const threadInfos = useSelector(state => state.threadStore.threadInfos);
+ const threadInfos = useSelector(thickRawThreadInfosSelector);
const entryInfos = useSelector(state => state.entryStore.entryInfos);
const findUserIdentities = useFindUserIdentities();
const loggedInUserInfo = useLoggedInUserInfo();
diff --git a/lib/shared/dm-ops/edit-entry-spec.js b/lib/shared/dm-ops/edit-entry-spec.js
--- a/lib/shared/dm-ops/edit-entry-spec.js
+++ b/lib/shared/dm-ops/edit-entry-spec.js
@@ -63,7 +63,7 @@
createMessageDataWithInfoFromDMOperation(dmOperation);
const rawMessageInfos = [rawMessageInfo];
- invariant(rawEntryInfo?.thick, 'Entry thread should be thick');
+ invariant(rawEntryInfo?.thick, 'Entry should be thick');
const timestamp = rawEntryInfo.lastUpdatedTime;
if (timestamp > time) {
diff --git a/lib/shared/dm-ops/join-thread-spec.js b/lib/shared/dm-ops/join-thread-spec.js
--- a/lib/shared/dm-ops/join-thread-spec.js
+++ b/lib/shared/dm-ops/join-thread-spec.js
@@ -58,13 +58,6 @@
const { joinerID, time, existingThreadDetails } = dmOperation;
const { viewerID, threadInfos } = utilities;
const currentThreadInfo = threadInfos[existingThreadDetails.threadID];
- if (currentThreadInfo && !currentThreadInfo.thick) {
- return {
- rawMessageInfos: [],
- updateInfos: [],
- blobOps: [],
- };
- }
const { rawMessageInfo } =
createMessageDataWithInfoFromDMOperation(dmOperation);
@@ -149,10 +142,6 @@
'thick thread but is missing from the store',
);
}
- invariant(
- !parentThreadInfo || parentThreadInfo.thick,
- 'Parent thread should be thick',
- );
const { membershipPermissions } = createRoleAndPermissionForThickThreads(
currentThreadInfo.type,
diff --git a/lib/shared/dm-ops/leave-thread-spec.js b/lib/shared/dm-ops/leave-thread-spec.js
--- a/lib/shared/dm-ops/leave-thread-spec.js
+++ b/lib/shared/dm-ops/leave-thread-spec.js
@@ -1,6 +1,5 @@
// @flow
-import invariant from 'invariant';
import uuid from 'uuid';
import { createPermissionsInfo } from './create-thread-spec.js';
@@ -16,7 +15,7 @@
import type { ThickRawThreadInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
import { minimallyEncodeThreadCurrentUserInfo } from '../../types/minimally-encoded-thread-permissions-types.js';
import { threadTypes } from '../../types/thread-types-enum.js';
-import type { RawThreadInfos } from '../../types/thread-types.js';
+import type { ThickRawThreadInfos } from '../../types/thread-types.js';
import { updateTypes } from '../../types/update-types-enum.js';
import type { ClientUpdateInfo } from '../../types/update-types.js';
import { values } from '../../utils/objects.js';
@@ -39,7 +38,7 @@
function createDeleteSubthreadsUpdates(
dmOperation: DMLeaveThreadOperation,
threadInfo: ThickRawThreadInfo,
- threadInfos: RawThreadInfos,
+ threadInfos: ThickRawThreadInfos,
): Array<ClientUpdateInfo> {
const updates: Array<ClientUpdateInfo> = [];
for (const thread of values(threadInfos)) {
@@ -61,11 +60,11 @@
function createLeaveSubthreadsUpdates(
dmOperation: DMLeaveThreadOperation,
threadInfo: ThickRawThreadInfo,
- threadInfos: RawThreadInfos,
+ threadInfos: ThickRawThreadInfos,
): Array<ClientUpdateInfo> {
const updates: Array<ClientUpdateInfo> = [];
for (const thread of values(threadInfos)) {
- if (thread.parentThreadID !== threadInfo.id || !thread.thick) {
+ if (thread.parentThreadID !== threadInfo.id) {
continue;
}
@@ -123,7 +122,6 @@
const { editorID, time, threadID } = dmOperation;
const { viewerID, threadInfos } = utilities;
const threadInfo = threadInfos[threadID];
- invariant(threadInfo.thick, 'Thread should be thick');
const { rawMessageInfo } =
createMessageDataWithInfoFromDMOperation(dmOperation);
@@ -180,10 +178,6 @@
'leaving a thread but is missing from the store',
);
}
- invariant(
- parentThreadInfo?.thick,
- 'Parent thread should be present and thick',
- );
const viewerMembershipPermissions = createPermissionsInfo(
threadID,
threadInfo.type,
diff --git a/lib/shared/dm-ops/remove-members-spec.js b/lib/shared/dm-ops/remove-members-spec.js
--- a/lib/shared/dm-ops/remove-members-spec.js
+++ b/lib/shared/dm-ops/remove-members-spec.js
@@ -1,6 +1,5 @@
// @flow
-import invariant from 'invariant';
import uuid from 'uuid';
import type {
@@ -50,7 +49,6 @@
const { time, threadID, removedUserIDs } = dmOperation;
const { viewerID, threadInfos } = utilities;
const threadInfo = threadInfos[threadID];
- invariant(threadInfo.thick, 'Thread should be thick');
const { rawMessageInfo } =
createMessageDataWithInfoFromDMOperation(dmOperation);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 7:31 AM (19 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584302
Default Alt Text
D13842.id45509.diff (10 KB)
Attached To
Mode
D13842: [lib] Tighten utils type to contain only thick threads
Attached
Detach File
Event Timeline
Log In to Comment