Page MenuHomePhabricator

D12164.diff
No OneTemporary

D12164.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
@@ -1,7 +1,6 @@
// @flow
import invariant from 'invariant';
-import _filter from 'lodash/fp/filter.js';
import _flow from 'lodash/fp/flow.js';
import _groupBy from 'lodash/fp/groupBy.js';
import _isEqual from 'lodash/fp/isEqual.js';
@@ -109,15 +108,6 @@
)([...entryInfos]);
}
-function filterExistingDaysToEntriesWithNewEntryInfos(
- oldDaysToEntries: { +[id: string]: string[] },
- newEntryInfos: { +[id: string]: RawEntryInfo },
-) {
- return _mapValues((entryIDs: string[]) =>
- _filter((id: string) => newEntryInfos[id])(entryIDs),
- )(oldDaysToEntries);
-}
-
function mergeNewEntryInfosOps(
currentEntryInfos: { +[id: string]: RawEntryInfo },
currentDaysToEntries: ?{ +[day: string]: string[] },
@@ -524,21 +514,22 @@
};
}
// Make sure the entry is in sync with its latest revision
- const newEntryInfos = {
- ...entryInfos,
- [id]: {
- ...entryInfos[id],
- text: action.payload.text,
- deleted: action.payload.deleted,
+ const ops = [
+ {
+ type: 'replace_entry',
+ payload: {
+ id,
+ entry: {
+ ...entryInfos[id],
+ text: action.payload.text,
+ deleted: action.payload.deleted,
+ },
+ },
},
- };
+ ];
return {
- entryStore: {
- entryInfos: newEntryInfos,
- daysToEntries,
- lastUserInteractionCalendar,
- },
- entryStoreOperations: [],
+ entryStore: entryStoreOpsHandlers.processStoreOperations(entryStore, ops),
+ entryStoreOperations: ops,
reportCreationRequests: [],
};
} else if (action.type === restoreEntryActionTypes.success) {
@@ -646,17 +637,21 @@
reportCreationRequests: [],
};
}
- const newDaysToEntries = filterExistingDaysToEntriesWithNewEntryInfos(
- daysToEntries,
- newEntryInfos,
- );
- return {
- entryStore: {
- entryInfos: newEntryInfos,
- daysToEntries: newDaysToEntries,
- lastUserInteractionCalendar,
+ const ops = [
+ {
+ type: 'remove_all_entries',
},
- entryStoreOperations: [],
+ ...Object.entries(newEntryInfos).map(([id, entry]) => ({
+ type: 'replace_entry',
+ payload: {
+ id,
+ entry,
+ },
+ })),
+ ];
+ return {
+ entryStore: entryStoreOpsHandlers.processStoreOperations(entryStore, ops),
+ entryStoreOperations: ops,
reportCreationRequests: [],
};
} else if (action.type === processServerRequestsActionType) {

File Metadata

Mime Type
text/plain
Expires
Sun, Sep 29, 7:51 AM (22 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2199490
Default Alt Text
D12164.diff (2 KB)

Event Timeline