Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3366231
D13347.id44201.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D13347.id44201.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D13347: [lib] check timestamps before processing edit entry operation
Attached
Detach File
Event Timeline
Log In to Comment