Page MenuHomePhorge

D14875.1765013096.diff
No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None

D14875.1765013096.diff

diff --git a/lib/backup/restored-migrations.js b/lib/backup/restored-migrations.js
--- a/lib/backup/restored-migrations.js
+++ b/lib/backup/restored-migrations.js
@@ -1,6 +1,7 @@
// @flow
import { sharedMigrations } from './persist-shared-migrations.js';
+import { createReplaceSyncedMetadataOperation } from '../ops/synced-metadata-store-ops.js';
import { databaseIdentifier } from '../types/database-identifier-types.js';
import { syncedMetadataNames } from '../types/synced-metadata-types.js';
import { getConfig } from '../utils/config.js';
@@ -54,13 +55,10 @@
const ops = await sharedMigrations[versionKey](
databaseIdentifier.RESTORED,
);
- const versionUpdateOp = {
- type: 'replace_synced_metadata_entry',
- payload: {
- name: syncedMetadataNames.STORE_VERSION,
- data: versionKey.toString(),
- },
- };
+ const versionUpdateOp = createReplaceSyncedMetadataOperation(
+ syncedMetadataNames.STORE_VERSION,
+ versionKey.toString(),
+ );
const dbOps = {
...ops,
syncedMetadataStoreOperations: [
diff --git a/lib/ops/synced-metadata-store-ops.js b/lib/ops/synced-metadata-store-ops.js
--- a/lib/ops/synced-metadata-store-ops.js
+++ b/lib/ops/synced-metadata-store-ops.js
@@ -3,6 +3,7 @@
import type { BaseStoreOpsHandlers } from './base-ops.js';
import type {
SyncedMetadata,
+ SyncedMetadataName,
SyncedMetadataStore,
} from '../types/synced-metadata-types.js';
@@ -98,4 +99,17 @@
},
};
-export { syncedMetadataStoreOpsHandlers };
+function createReplaceSyncedMetadataOperation(
+ name: SyncedMetadataName,
+ data: string,
+): ReplaceSyncedMetadataEntryOperation {
+ return {
+ type: 'replace_synced_metadata_entry',
+ payload: {
+ name,
+ data,
+ },
+ };
+}
+
+export { syncedMetadataStoreOpsHandlers, createReplaceSyncedMetadataOperation };
diff --git a/lib/reducers/alert-reducer.js b/lib/reducers/alert-reducer.js
--- a/lib/reducers/alert-reducer.js
+++ b/lib/reducers/alert-reducer.js
@@ -6,6 +6,7 @@
} from '../actions/alert-actions.js';
import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import type { SyncedMetadataStoreOperation } from '../ops/synced-metadata-store-ops.js';
+import { createReplaceSyncedMetadataOperation } from '../ops/synced-metadata-store-ops.js';
import type { AlertStore } from '../types/alert-types.js';
import type { BaseAction } from '../types/redux-types';
import { syncedMetadataNames } from '../types/synced-metadata-types.js';
@@ -21,13 +22,10 @@
return {
alertStore,
syncedMetadataStoreOperations: [
- {
- type: 'replace_synced_metadata_entry',
- payload: {
- name: syncedMetadataNames.ALERT_STORE,
- data: JSON.stringify(alertStore),
- },
- },
+ createReplaceSyncedMetadataOperation(
+ syncedMetadataNames.ALERT_STORE,
+ JSON.stringify(alertStore),
+ ),
],
};
}
diff --git a/lib/reducers/enabled-apps-reducer.js b/lib/reducers/enabled-apps-reducer.js
--- a/lib/reducers/enabled-apps-reducer.js
+++ b/lib/reducers/enabled-apps-reducer.js
@@ -3,6 +3,7 @@
import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js';
import type { SyncedMetadataStoreOperation } from '../ops/synced-metadata-store-ops.js';
+import { createReplaceSyncedMetadataOperation } from '../ops/synced-metadata-store-ops.js';
import type { EnabledApps } from '../types/enabled-apps.js';
import {
defaultEnabledApps,
@@ -27,13 +28,10 @@
return {
enabledApps,
syncedMetadataStoreOperations: [
- {
- type: 'replace_synced_metadata_entry',
- payload: {
- name: syncedMetadataNames.ENABLED_APPS,
- data: JSON.stringify(enabledApps),
- },
- },
+ createReplaceSyncedMetadataOperation(
+ syncedMetadataNames.ENABLED_APPS,
+ JSON.stringify(enabledApps),
+ ),
],
};
}
diff --git a/lib/reducers/theme-reducer.js b/lib/reducers/theme-reducer.js
--- a/lib/reducers/theme-reducer.js
+++ b/lib/reducers/theme-reducer.js
@@ -5,6 +5,7 @@
import { legacyLogInActionTypes } from '../actions/user-actions.js';
import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js';
import type { SyncedMetadataStoreOperation } from '../ops/synced-metadata-store-ops.js';
+import { createReplaceSyncedMetadataOperation } from '../ops/synced-metadata-store-ops.js';
import type { BaseAction } from '../types/redux-types.js';
import { syncedMetadataNames } from '../types/synced-metadata-types.js';
import {
@@ -25,13 +26,10 @@
return {
globalThemeInfo,
syncedMetadataStoreOperations: [
- {
- type: 'replace_synced_metadata_entry',
- payload: {
- name: syncedMetadataNames.GLOBAL_THEME_INFO,
- data: JSON.stringify(globalThemeInfo),
- },
- },
+ createReplaceSyncedMetadataOperation(
+ syncedMetadataNames.GLOBAL_THEME_INFO,
+ JSON.stringify(globalThemeInfo),
+ ),
],
};
}
diff --git a/lib/types/synced-metadata-types.js b/lib/types/synced-metadata-types.js
--- a/lib/types/synced-metadata-types.js
+++ b/lib/types/synced-metadata-types.js
@@ -13,7 +13,7 @@
GLOBAL_THEME_INFO: 'global_theme_info',
ALERT_STORE: 'alert_store',
});
-type SyncedMetadataName = $Values<typeof syncedMetadataNames>;
+export type SyncedMetadataName = $Values<typeof syncedMetadataNames>;
export type SetSyncedMetadataEntryPayload = {
+name: SyncedMetadataName,
diff --git a/lib/utils/migration-utils.js b/lib/utils/migration-utils.js
--- a/lib/utils/migration-utils.js
+++ b/lib/utils/migration-utils.js
@@ -7,6 +7,7 @@
import type { TranslatedThreadMessageInfos } from './message-ops-utils.js';
import { entries } from './objects.js';
import { convertRawThreadInfoToNewIDSchema } from '../_generated/migration-utils.js';
+import { createReplaceSyncedMetadataOperation } from '../ops/synced-metadata-store-ops.js';
import {
parsePendingThreadID,
getPendingThreadID,
@@ -297,13 +298,10 @@
const { state: newState, ops } =
await migrations[versionKey](migratedState);
migratedState = newState;
- const versionUpdateOp = {
- type: 'replace_synced_metadata_entry',
- payload: {
- name: syncedMetadataNames.STORE_VERSION,
- data: versionKey.toString(),
- },
- };
+ const versionUpdateOp = createReplaceSyncedMetadataOperation(
+ syncedMetadataNames.STORE_VERSION,
+ versionKey.toString(),
+ );
const dbOps = {
...ops,
syncedMetadataStoreOperations: [

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 6, 9:24 AM (5 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5835792
Default Alt Text
D14875.1765013096.diff (6 KB)

Event Timeline