Page MenuHomePhabricator

D13348.id44253.diff
No OneTemporary

D13348.id44253.diff

diff --git a/lib/shared/dm-ops/delete-entry-spec.js b/lib/shared/dm-ops/delete-entry-spec.js
--- a/lib/shared/dm-ops/delete-entry-spec.js
+++ b/lib/shared/dm-ops/delete-entry-spec.js
@@ -1,5 +1,6 @@
// @flow
+import invariant from 'invariant';
import uuid from 'uuid';
import type {
@@ -7,7 +8,6 @@
ProcessDMOperationUtilities,
} from './dm-op-spec.js';
import type { DMDeleteEntryOperation } from '../../types/dm-ops.js';
-import type { ThickRawEntryInfo } from '../../types/entry-types.js';
import { messageTypes } from '../../types/message-types-enum.js';
import { updateTypes } from '../../types/update-types-enum.js';
import type { EntryUpdateInfo } from '../../types/update-types.js';
@@ -33,7 +33,11 @@
const messageData = createMessageDataFromDMOperation(dmOperation);
return { messageDatas: [messageData] };
},
- processDMOperation: async (dmOperation: DMDeleteEntryOperation) => {
+ processDMOperation: async (
+ dmOperation: DMDeleteEntryOperation,
+ viewerID: string,
+ utilities: ProcessDMOperationUtilities,
+ ) => {
const {
threadID,
creatorID,
@@ -45,13 +49,24 @@
messageID,
} = dmOperation;
+ const rawEntryInfo = utilities.entryInfos[entryID];
const messageData = createMessageDataFromDMOperation(dmOperation);
const rawMessageInfos = [
rawMessageInfoFromMessageData(messageData, messageID),
];
+ invariant(rawEntryInfo?.thick, 'Entry thread should be thick');
+ const timestamp = rawEntryInfo.lastUpdatedTime;
+
+ if (timestamp > time) {
+ return {
+ rawMessageInfos,
+ updateInfos: [],
+ };
+ }
+
const date = dateFromString(dateString);
- const rawEntryInfo: ThickRawEntryInfo = {
+ const rawEntryInfoToUpdate = {
id: entryID,
threadID,
text: prevText,
@@ -66,7 +81,7 @@
};
const entryUpdateInfo: EntryUpdateInfo = {
- entryInfo: rawEntryInfo,
+ entryInfo: rawEntryInfoToUpdate,
type: updateTypes.UPDATE_ENTRY,
id: uuid.v4(),
time,

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 10:51 PM (11 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2705822
Default Alt Text
D13348.id44253.diff (2 KB)

Event Timeline