Page MenuHomePhabricator

D12163.id40512.diff
No OneTemporary

D12163.id40512.diff

diff --git a/lib/reducers/entry-reducer.js b/lib/reducers/entry-reducer.js
--- a/lib/reducers/entry-reducer.js
+++ b/lib/reducers/entry-reducer.js
@@ -11,7 +11,6 @@
import _omitBy from 'lodash/fp/omitBy.js';
import _pickBy from 'lodash/fp/pickBy.js';
import _sortBy from 'lodash/fp/sortBy.js';
-import _union from 'lodash/fp/union.js';
import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import {
@@ -341,26 +340,21 @@
const entryInfo = action.payload;
const localID = entryInfo.localID;
invariant(localID, 'localID should be set in CREATE_LOCAL_ENTRY');
- const newEntryInfos = {
- ...entryInfos,
- [(localID: string)]: entryInfo,
- };
- const dayString = dateString(
- entryInfo.year,
- entryInfo.month,
- entryInfo.day,
- );
- const newDaysToEntries = {
- ...daysToEntries,
- [dayString]: _union([localID])(daysToEntries[dayString]),
- };
+ const ops = [
+ {
+ type: 'replace_entry',
+ payload: {
+ id: localID,
+ entry: entryInfo,
+ },
+ },
+ ];
return {
entryStore: {
- entryInfos: newEntryInfos,
- daysToEntries: newDaysToEntries,
+ ...entryStoreOpsHandlers.processStoreOperations(entryStore, ops),
lastUserInteractionCalendar: Date.now(),
},
- entryStoreOperations: [],
+ entryStoreOperations: ops,
reportCreationRequests: [],
};
} else if (action.type === createEntryActionTypes.success) {
@@ -446,20 +440,21 @@
reportCreationRequests: [],
};
}
- const newEntryInfos = {
- ...entryInfos,
- [payload.id]: {
- ...entryInfos[payload.id],
- text: payload.dbText,
+ const ops = [
+ {
+ type: 'replace_entry',
+ payload: {
+ id: payload.id,
+ entry: {
+ ...entryInfos[payload.id],
+ text: payload.dbText,
+ },
+ },
},
- };
+ ];
return {
- entryStore: {
- entryInfos: newEntryInfos,
- daysToEntries,
- lastUserInteractionCalendar,
- },
- entryStoreOperations: [],
+ entryStore: entryStoreOpsHandlers.processStoreOperations(entryStore, ops),
+ entryStoreOperations: ops,
reportCreationRequests: [],
};
} else if (action.type === deleteEntryActionTypes.started) {
@@ -469,20 +464,24 @@
? payload.serverID
: payload.localID;
invariant(id, 'either serverID or localID should be set');
- const newEntryInfos = {
- ...entryInfos,
- [(id: string)]: {
- ...entryInfos[id],
- deleted: true,
+ const ops = [
+ {
+ type: 'replace_entry',
+ payload: {
+ id,
+ entry: {
+ ...entryInfos[id],
+ deleted: true,
+ },
+ },
},
- };
+ ];
return {
entryStore: {
- entryInfos: newEntryInfos,
- daysToEntries,
+ ...entryStoreOpsHandlers.processStoreOperations(entryStore, ops),
lastUserInteractionCalendar: Date.now(),
},
- entryStoreOperations: [],
+ entryStoreOperations: ops,
reportCreationRequests: [],
};
} else if (action.type === deleteEntryActionTypes.success) {

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 29, 1:53 AM (8 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2730121
Default Alt Text
D12163.id40512.diff (3 KB)

Event Timeline