Save appearance settings on server

- app theme
- theme mode
- pure black mode
- manga grid item width
This commit is contained in:
schroda
2025-05-17 21:04:44 +02:00
parent 4a1eb6f824
commit 18ddf46f17
11 changed files with 88 additions and 60 deletions

View File

@@ -89,6 +89,10 @@ const APP_METADATA_OBJECT: Record<AppMetadataKeys, undefined> = {
showNsfw: undefined,
shouldUseInfiniteScroll: undefined,
shouldShowTransitionPage: undefined,
appTheme: undefined,
themeMode: undefined,
shouldUsePureBlackMode: undefined,
mangaGridItemWidth: undefined,
};
export const VALID_APP_METADATA_KEYS = Object.keys(APP_METADATA_OBJECT);

View File

@@ -21,7 +21,7 @@ export interface IMetadataMigration {
* Otherwise, all metadata keys will get migrated.
*/
key?: string;
oldValue: string | RegExp;
oldValue: string | RegExp | undefined;
newValue: string | ((oldValue: string) => string);
}[];
keys?: { oldKey: string; newKey: string }[];

View File

@@ -83,7 +83,10 @@ const applyMetadataValueMigration = (meta: Metadata, migration: IMetadataMigrati
metadataValueChanges.forEach(({ key, oldValue, newValue }) => {
const migrateValue = (metaKey: string) => {
if (meta[metaKey].match(oldValue)) {
if (
(oldValue === undefined && meta[metaKey] === oldValue) ||
(oldValue !== undefined && meta[metaKey].match(oldValue))
) {
migratedMetadata[metaKey] = typeof newValue === 'function' ? newValue(meta[metaKey]) : newValue;
}
};