Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3356878
D13195.id43751.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
D13195.id43751.diff
View Options
diff --git a/lib/actions/thread-actions.js b/lib/actions/thread-actions.js
--- a/lib/actions/thread-actions.js
+++ b/lib/actions/thread-actions.js
@@ -16,7 +16,7 @@
import { permissionsAndAuthRelatedRequestTimeout } from '../shared/timeouts.js';
import type {
DMChangeThreadSettingsOperation,
- DMThreadSettingsChangesBase,
+ DMThreadSettingsChanges,
} from '../types/dm-ops.js';
import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
import {
@@ -132,7 +132,7 @@
invariant(viewerID, 'viewerID should be set');
- const changes: { ...DMThreadSettingsChangesBase } = {};
+ const changes: { ...DMThreadSettingsChanges } = {};
if (input.changes.name) {
changes.name = input.changes.name;
}
diff --git a/lib/shared/dm-ops/change-thread-settings-and-add-viewer-spec.js b/lib/shared/dm-ops/change-thread-settings-and-add-viewer-spec.js
deleted file mode 100644
--- a/lib/shared/dm-ops/change-thread-settings-and-add-viewer-spec.js
+++ /dev/null
@@ -1,103 +0,0 @@
-// @flow
-
-import {
- addViewerToThreadMembersSpec,
- createAddViewerToThreadMembersResults,
- createAddViewerToThreadMembersMessageDataFromDMOp,
-} from './add-viewer-to-thread-members-spec.js';
-import {
- processChangeSettingsOperation,
- createChangeSettingsMessageDatasAndUpdate,
-} from './change-thread-settings-spec.js';
-import type {
- DMOperationSpec,
- ProcessDMOperationUtilities,
-} from './dm-op-spec.js';
-import type { DMChangeThreadSettingsAndAddViewerOperation } from '../../types/dm-ops.js';
-import type { MessageData } from '../../types/message-types.js';
-import { values } from '../../utils/objects.js';
-
-function createAddViewerAndMembersOperation(
- dmOperation: DMChangeThreadSettingsAndAddViewerOperation,
-) {
- const { editorID, time, messageIDsPrefix, changes, existingThreadDetails } =
- dmOperation;
- const newMemberIDs =
- changes.newMemberIDs && changes.newMemberIDs.length > 0
- ? [...new Set(changes.newMemberIDs)]
- : [];
- return {
- type: 'add_viewer_to_thread_members',
- editorID,
- time,
- messageID: `${messageIDsPrefix}/add_members`,
- addedUserIDs: newMemberIDs,
- existingThreadDetails,
- };
-}
-
-function processAddViewerToThreadMembersOperation(
- dmOperation: DMChangeThreadSettingsAndAddViewerOperation,
- viewerID: string,
-) {
- const operation = createAddViewerAndMembersOperation(dmOperation);
- if (operation.addedUserIDs.length === 0) {
- return null;
- }
- return createAddViewerToThreadMembersResults(operation, viewerID);
-}
-
-const changeThreadSettingsAndAddViewerSpec: DMOperationSpec<DMChangeThreadSettingsAndAddViewerOperation> =
- Object.freeze({
- notificationsCreationData: async (
- dmOperation: DMChangeThreadSettingsAndAddViewerOperation,
- ) => {
- const messageDatas: Array<MessageData> = [];
- const addNewMembersOperation =
- createAddViewerAndMembersOperation(dmOperation);
- if (addNewMembersOperation) {
- const addNewMembersMessageData =
- createAddViewerToThreadMembersMessageDataFromDMOp(
- addNewMembersOperation,
- );
- messageDatas.push(addNewMembersMessageData);
- }
-
- const { fieldNameToMessageData } =
- createChangeSettingsMessageDatasAndUpdate(dmOperation);
- messageDatas.push(...values(fieldNameToMessageData));
- return { messageDatas };
- },
- processDMOperation: async (
- dmOperation: DMChangeThreadSettingsAndAddViewerOperation,
- viewerID: string,
- utilities: ProcessDMOperationUtilities,
- ) => {
- const addMembersResult = processAddViewerToThreadMembersOperation(
- dmOperation,
- viewerID,
- );
-
- return processChangeSettingsOperation(
- dmOperation,
- viewerID,
- utilities,
- addMembersResult,
- );
- },
- canBeProcessed(
- dmOperation: DMChangeThreadSettingsAndAddViewerOperation,
- viewerID: string,
- utilities: ProcessDMOperationUtilities,
- ) {
- const operation = createAddViewerAndMembersOperation(dmOperation);
- return addViewerToThreadMembersSpec.canBeProcessed(
- operation,
- viewerID,
- utilities,
- );
- },
- supportsAutoRetry: true,
- });
-
-export { changeThreadSettingsAndAddViewerSpec };
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
@@ -3,11 +3,6 @@
import invariant from 'invariant';
import uuid from 'uuid';
-import {
- type AddMembersResult,
- createAddNewMembersResults,
- createAddNewMembersMessageDataFromDMOperation,
-} from './add-members-spec.js';
import type {
DMOperationSpec,
ProcessDMOperationUtilities,
@@ -16,7 +11,7 @@
DMChangeThreadSettingsAndAddViewerOperation,
DMChangeThreadSettingsOperation,
DMOperationResult,
- DMThreadSettingsChangesBase,
+ DMThreadSettingsChanges,
} from '../../types/dm-ops.js';
import type { MessageData, RawMessageInfo } from '../../types/message-types';
import { messageTypes } from '../../types/message-types-enum.js';
@@ -27,39 +22,6 @@
import { values } from '../../utils/objects.js';
import { rawMessageInfoFromMessageData } from '../message-utils.js';
-function createAddMembersOperation(
- dmOperation: DMChangeThreadSettingsOperation,
-) {
- const { editorID, time, messageIDsPrefix, changes, threadID } = dmOperation;
- const newMemberIDs =
- changes.newMemberIDs && changes.newMemberIDs.length > 0
- ? [...new Set(changes.newMemberIDs)]
- : [];
- if (!changes.newMemberIDs || changes.newMemberIDs.length === 0) {
- return null;
- }
- return {
- type: 'add_members',
- editorID,
- time,
- messageID: `${messageIDsPrefix}/add_members`,
- addedUserIDs: newMemberIDs,
- threadID,
- };
-}
-
-function processAddMembersOperation(
- dmOperation: DMChangeThreadSettingsOperation,
- viewerID: string,
- utilities: ProcessDMOperationUtilities,
-) {
- const operation = createAddMembersOperation(dmOperation);
- if (!operation) {
- return null;
- }
- return createAddNewMembersResults(operation, viewerID, utilities);
-}
-
function getThreadIDFromChangeThreadSettingsDMOp(
dmOperation:
| DMChangeThreadSettingsOperation
@@ -76,13 +38,13 @@
| DMChangeThreadSettingsAndAddViewerOperation,
): {
+fieldNameToMessageData: { +[fieldName: string]: ChangeSettingsMessageData },
- +threadInfoUpdate: DMThreadSettingsChangesBase,
+ +threadInfoUpdate: DMThreadSettingsChanges,
} {
const { changes, editorID, time } = dmOperation;
const { name, description, color, avatar } = changes;
const threadID = getThreadIDFromChangeThreadSettingsDMOp(dmOperation);
- const threadInfoUpdate: { ...DMThreadSettingsChangesBase } = {};
+ const threadInfoUpdate: { ...DMThreadSettingsChanges } = {};
if (name !== undefined && name !== null) {
threadInfoUpdate.name = name;
@@ -130,7 +92,6 @@
| DMChangeThreadSettingsAndAddViewerOperation,
viewerID: string,
utilities: ProcessDMOperationUtilities,
- addMembersResult: ?AddMembersResult,
): DMOperationResult {
const { time, messageIDsPrefix } = dmOperation;
const threadID = getThreadIDFromChangeThreadSettingsDMOp(dmOperation);
@@ -139,14 +100,6 @@
const updateInfos: Array<ClientUpdateInfo> = [];
const rawMessageInfos: Array<RawMessageInfo> = [];
- if (addMembersResult) {
- if (addMembersResult.threadInfo) {
- threadInfoToUpdate = addMembersResult.threadInfo;
- }
- updateInfos.push(...addMembersResult.updateInfos);
- rawMessageInfos.push(...addMembersResult.rawMessageInfos);
- }
-
invariant(threadInfoToUpdate?.thick, 'Thread should be thick');
const { fieldNameToMessageData, threadInfoUpdate } =
createChangeSettingsMessageDatasAndUpdate(dmOperation);
@@ -187,12 +140,6 @@
dmOperation: DMChangeThreadSettingsOperation,
) => {
const messageDatas: Array<MessageData> = [];
- const addNewMembersOperation = createAddMembersOperation(dmOperation);
- if (addNewMembersOperation) {
- const addNewMembersMessageData =
- createAddNewMembersMessageDataFromDMOperation(addNewMembersOperation);
- messageDatas.push(addNewMembersMessageData);
- }
const { fieldNameToMessageData } =
createChangeSettingsMessageDatasAndUpdate(dmOperation);
@@ -204,18 +151,7 @@
viewerID: string,
utilities: ProcessDMOperationUtilities,
) => {
- const addMembersResult = processAddMembersOperation(
- dmOperation,
- viewerID,
- utilities,
- );
-
- return processChangeSettingsOperation(
- dmOperation,
- viewerID,
- utilities,
- addMembersResult,
- );
+ return processChangeSettingsOperation(dmOperation, viewerID, utilities);
},
canBeProcessed(
dmOperation: DMChangeThreadSettingsOperation,
diff --git a/lib/shared/dm-ops/dm-op-specs.js b/lib/shared/dm-ops/dm-op-specs.js
--- a/lib/shared/dm-ops/dm-op-specs.js
+++ b/lib/shared/dm-ops/dm-op-specs.js
@@ -2,7 +2,6 @@
import { addMembersSpec } from './add-members-spec.js';
import { addViewerToThreadMembersSpec } from './add-viewer-to-thread-members-spec.js';
-import { changeThreadSettingsAndAddViewerSpec } from './change-thread-settings-and-add-viewer-spec.js';
import { changeThreadSettingsSpec } from './change-thread-settings-spec.js';
import { createSidebarSpec } from './create-sidebar-spec.js';
import { createThreadSpec } from './create-thread-spec.js';
@@ -29,6 +28,4 @@
[dmOperationTypes.LEAVE_THREAD]: leaveThreadSpec,
[dmOperationTypes.REMOVE_MEMBERS]: removeMembersSpec,
[dmOperationTypes.CHANGE_THREAD_SETTINGS]: changeThreadSettingsSpec,
- [dmOperationTypes.CHANGE_THREAD_SETTINGS_AND_ADD_VIEWER]:
- changeThreadSettingsAndAddViewerSpec,
});
diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js
--- a/lib/types/dm-ops.js
+++ b/lib/types/dm-ops.js
@@ -264,18 +264,13 @@
removedUserIDs: t.list(tUserID),
});
-export type DMThreadSettingsChangesBase = {
+export type DMThreadSettingsChanges = {
+name?: string,
+description?: string,
+color?: string,
+avatar?: ClientAvatar,
};
-type DMThreadSettingsChanges = $ReadOnly<{
- ...DMThreadSettingsChangesBase,
- +newMemberIDs?: $ReadOnlyArray<string>,
-}>;
-
type DMChangeThreadSettingsBase = {
+editorID: string,
+time: number,
@@ -291,7 +286,6 @@
name: t.maybe(t.String),
description: t.maybe(t.String),
color: t.maybe(tColor),
- newMemberIDs: t.maybe(t.list(tUserID)),
avatar: t.maybe(clientAvatarValidator),
}),
messageIDsPrefix: t.String,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 9:09 PM (20 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577340
Default Alt Text
D13195.id43751.diff (10 KB)
Attached To
Mode
D13195: [lib] remove `newMemberIDs` from `DMThreadSettingsChanges`
Attached
Detach File
Event Timeline
Log In to Comment