Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3569391
D12147.id40524.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12147.id40524.diff
View Options
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
@@ -13,6 +13,7 @@
import _sortBy from 'lodash/fp/sortBy.js';
import _union from 'lodash/fp/union.js';
+import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import {
fetchEntriesActionTypes,
updateCalendarQueryActionTypes,
@@ -45,6 +46,7 @@
import { stateSyncSpecs } from '../shared/state-sync/state-sync-specs.js';
import { threadInFilterList } from '../shared/thread-utils.js';
import { updateSpecs } from '../shared/updates/update-specs.js';
+import { isWebPlatform } from '../types/device-types.js';
import type { RawEntryInfo, EntryStore } from '../types/entry-types.js';
import type { BaseAction } from '../types/redux-types.js';
import { type ClientEntryInconsistencyReportCreationRequest } from '../types/report-types.js';
@@ -62,10 +64,37 @@
processUpdatesActionType,
} from '../types/update-types.js';
import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
+import { getConfig } from '../utils/config.js';
import { dateString } from '../utils/date-utils.js';
-import { values } from '../utils/objects.js';
+import { getMessageForException } from '../utils/errors.js';
+import { assertObjectsAreEqual, values } from '../utils/objects.js';
import { relyingOnAuthoritativeKeyserver } from '../utils/services-utils.js';
+function assertEntryStoresAreEqual(
+ processedEntryStore: EntryStore,
+ expectedEntryStore: EntryStore,
+ location: string,
+ onStateDifference?: (message: string) => mixed,
+) {
+ try {
+ assertObjectsAreEqual(
+ processedEntryStore,
+ expectedEntryStore,
+ `EntryStore - ${location}`,
+ );
+ } catch (e) {
+ console.log(
+ 'Error processing EntryStore ops',
+ processedEntryStore,
+ expectedEntryStore,
+ );
+ const message = `Error processing EntryStore ops ${
+ getMessageForException(e) ?? '{no exception message}'
+ }`;
+ onStateDifference?.(message);
+ }
+}
+
function daysToEntriesFromEntryInfos(
entryInfos: $ReadOnlyArray<RawEntryInfo>,
): { [day: string]: string[] } {
@@ -167,6 +196,7 @@
entryStore: EntryStore,
action: BaseAction,
newThreadInfos: RawThreadInfos,
+ onStateDifference?: (message: string) => mixed,
): {
+entryStore: EntryStore,
+entryStoreOperations: $ReadOnlyArray<EntryStoreOperation>,
@@ -683,6 +713,26 @@
entryStoreOperations: [],
reportCreationRequests: newInconsistencies,
};
+ } else if (action.type === setClientDBStoreActionType) {
+ const entryInfosFromDB = action.payload.entries ?? {};
+ const newStore = {
+ entryInfos: entryInfosFromDB,
+ daysToEntries: daysToEntriesFromEntryInfos(values(entryInfosFromDB)),
+ lastUserInteractionCalendar,
+ };
+ if (!isWebPlatform(getConfig().platformDetails.platform)) {
+ assertEntryStoresAreEqual(
+ newStore,
+ entryStore,
+ action.type,
+ onStateDifference,
+ );
+ }
+ return {
+ entryStore,
+ entryStoreOperations: [],
+ reportCreationRequests: [],
+ };
}
return {
entryStore,
diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js
--- a/lib/reducers/master-reducer.js
+++ b/lib/reducers/master-reducer.js
@@ -55,7 +55,7 @@
const { threadInfos } = threadStore;
const { entryStore, reportCreationRequests: newEntryInconsistencies } =
- reduceEntryInfos(state.entryStore, action, threadInfos);
+ reduceEntryInfos(state.entryStore, action, threadInfos, onStateDifference);
const onStateDifferenceForStaff = (message: string) => {
const isCurrentUserStaff = state.currentUserInfo?.id
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 29, 1:47 AM (8 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2730118
Default Alt Text
D12147.id40524.diff (3 KB)
Attached To
Mode
D12147: [lib] Handle setClientDBStoreActionType for entries
Attached
Detach File
Event Timeline
Log In to Comment