Page MenuHomePhabricator

D13347.id44201.diff
No OneTemporary

D13347.id44201.diff

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
@@ -1,5 +1,6 @@
// @flow
+import invariant from 'invariant';
import uuid from 'uuid';
import type {
@@ -33,7 +34,11 @@
const messageData = createMessageDataFromDMOperation(dmOperation);
return { messageDatas: [messageData] };
},
- processDMOperation: async (dmOperation: DMEditEntryOperation) => {
+ processDMOperation: async (
+ dmOperation: DMEditEntryOperation,
+ viewerID: string,
+ utilities: ProcessDMOperationUtilities,
+ ) => {
const {
threadID,
creatorID,
@@ -45,28 +50,37 @@
messageID,
} = dmOperation;
+ const rawEntryInfo = utilities.entryInfos[entryID];
+
const messageData = createMessageDataFromDMOperation(dmOperation);
const rawMessageInfos = [
rawMessageInfoFromMessageData(messageData, messageID),
];
+ invariant(rawEntryInfo?.thick, 'Entry thread should be thick');
+ let rawEntryInfoToUpdate: ThickRawEntryInfo = rawEntryInfo;
const date = dateFromString(dateString);
- const rawEntryInfo: ThickRawEntryInfo = {
- id: entryID,
- threadID,
- text,
- year: date.getFullYear(),
- month: date.getMonth() + 1,
- day: date.getDate(),
- creationTime,
- creatorID,
- thick: true,
- deleted: false,
- lastUpdatedTime,
- };
+
+ const timestamp = rawEntryInfoToUpdate.lastUpdatedTime;
+
+ if (timestamp < lastUpdatedTime) {
+ rawEntryInfoToUpdate = {
+ id: entryID,
+ threadID,
+ text,
+ year: date.getFullYear(),
+ month: date.getMonth() + 1,
+ day: date.getDate(),
+ creationTime,
+ creatorID,
+ thick: true,
+ deleted: false,
+ lastUpdatedTime,
+ };
+ }
const entryUpdateInfo: EntryUpdateInfo = {
- entryInfo: rawEntryInfo,
+ entryInfo: rawEntryInfoToUpdate,
type: updateTypes.UPDATE_ENTRY,
id: uuid.v4(),
time: lastUpdatedTime,

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 10:16 AM (21 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2584261
Default Alt Text
D13347.id44201.diff (2 KB)

Event Timeline