Page MenuHomePhabricator

D12499.id41535.diff
No OneTemporary

D12499.id41535.diff

diff --git a/lib/shared/redux/client-db-utils.js b/lib/shared/redux/client-db-utils.js
--- a/lib/shared/redux/client-db-utils.js
+++ b/lib/shared/redux/client-db-utils.js
@@ -2,66 +2,17 @@
import _keyBy from 'lodash/fp/keyBy.js';
-import {
- threadStoreOpsHandlers,
- type ClientDBThreadStoreOperation,
- type ReplaceThreadOperation,
- type ThreadStoreOperation,
-} from '../../ops/thread-store-ops.js';
+import type { ClientDBThreadStoreOperation } from '../../ops/thread-store-ops.js';
import type {
RawThreadInfos,
- ThreadStore,
ClientDBThreadInfo,
} from '../../types/thread-types.js';
-import { entries, values } from '../../utils/objects.js';
+import { values } from '../../utils/objects.js';
import {
convertClientDBThreadInfoToRawThreadInfo,
convertRawThreadInfoToClientDBThreadInfo,
} from '../../utils/thread-ops-utils.js';
-function updateThreadStoreThreadInfos(
- threadStore: ThreadStore,
- migrationFunc: RawThreadInfos => RawThreadInfos,
-): {
- +newThreadStore: ThreadStore,
- +dbOperations: $ReadOnlyArray<ClientDBThreadStoreOperation>,
-} {
- const rawThreadInfos = threadStore.threadInfos;
-
- // 1. Convert `RawThreadInfo`s to a map of `threadID` => `threadInfo`.
- const keyedRawThreadInfos = _keyBy('id')(rawThreadInfos);
-
- // 2. Apply `migrationFunc` to `ThreadInfo`s.
- const updatedKeyedRawThreadInfos = migrationFunc(keyedRawThreadInfos);
-
- // 3. Construct `replace` `ThreadStoreOperation`s.
- const replaceOps: $ReadOnlyArray<ReplaceThreadOperation> = entries(
- updatedKeyedRawThreadInfos,
- ).map(([id, threadInfo]) => ({
- type: 'replace',
- payload: { id, threadInfo },
- }));
-
- // 4. Prepend `replaceOps` with `remove_all` ops
- const operations: $ReadOnlyArray<ThreadStoreOperation> = [
- { type: 'remove_all' },
- ...replaceOps,
- ];
-
- // 5. Process `ThreadStoreOperation`s to get new `ThreadStore`.
- const newThreadStore: ThreadStore =
- threadStoreOpsHandlers.processStoreOperations(threadStore, operations);
-
- // 6. Convert `ThreadStoreOperation`s to `ClientDBThreadStoreOperation`s.
- const dbOperations: $ReadOnlyArray<ClientDBThreadStoreOperation> =
- threadStoreOpsHandlers.convertOpsToClientDBOps(operations);
-
- return {
- newThreadStore,
- dbOperations,
- };
-}
-
function createUpdateDBOpsForThreadStoreThreadInfos(
clientDBThreadInfos: $ReadOnlyArray<ClientDBThreadInfo>,
migrationFunc: RawThreadInfos => RawThreadInfos,
@@ -95,7 +46,4 @@
return [{ type: 'remove_all' }, ...replaceThreadOperations];
}
-export {
- updateThreadStoreThreadInfos,
- createUpdateDBOpsForThreadStoreThreadInfos,
-};
+export { createUpdateDBOpsForThreadStoreThreadInfos };

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 10, 1:03 AM (13 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2832172
Default Alt Text
D12499.id41535.diff (2 KB)

Event Timeline