Merge "selected source/extension" languages

This commit is contained in:
schroda
2026-01-25 17:31:02 +01:00
parent dd1f5bd218
commit 4d7eb74a56
10 changed files with 46 additions and 24 deletions

View File

@@ -35,6 +35,7 @@ import { MetadataThemeSettings } from '@/features/theme/AppTheme.types.ts';
import { TapZoneInvertMode } from '@/features/reader/tap-zones/TapZoneLayout.types.ts';
import { detectLocale, getISOLanguage } from '@/lib/ISOLanguageUtil.ts';
import { i18nResources } from '@/i18n';
import { toUniqueLanguageCodes } from '@/base/utils/Languages.ts';
export const APP_METADATA_KEY_PREFIX = 'webUI';
@@ -333,10 +334,7 @@ export const APP_METADATA: Record<
showChapterNumber: {
convert: convertToBoolean,
},
extensionLanguages: {
convert: convertToObject<string[]>,
},
sourceLanguages: {
browseLanguages: {
convert: convertToObject<string[]>,
},
showNsfw: {
@@ -437,8 +435,7 @@ export const GLOBAL_METADATA_KEYS: AppMetadataKeys[] = [
// browse
'hideLibraryEntries',
'extensionLanguages',
'sourceLanguages',
'browseLanguages',
'showNsfw',
'lastUsedSourceId',
'shouldShowOnlySourcesWithResults',
@@ -490,11 +487,14 @@ export const GLOBAL_METADATA_KEYS: AppMetadataKeys[] = [
* getting migrated, the key in the value migration is the "old" key (before the migration to the
* new key).
*
* For new metadata migrations, the value migrations have already been applied while the key migrations are still outstanding (same as for the value migrations)
*
* Migration order (function "applyMetadataMigrations"):
* 1. app metadata key prefix
* 2. app metadata values
* 3. app metadata keys
* 4. app metadata keys deletion
* 3. create new app metadata with values from existing metadata
* 4. app metadata keys
* 5. app metadata keys deletion
*
* @example
* // changes:
@@ -666,4 +666,25 @@ export const METADATA_MIGRATIONS: IMetadataMigration[] = [
},
],
},
{
values: [
{
key: 'sourceLanguages',
oldValue: /^\[.*]$/g,
newValue: (sourceLanguagesValue, key, oldMetadata) => {
const extensionLanguagesKey = key.replace('sourceLanguages', 'extensionLanguages');
const extensionLanguagesValue = oldMetadata[extensionLanguagesKey];
const convertedSourceLanguages = convertToObject<string[]>(sourceLanguagesValue, []);
const convertedExtensionLanguages = convertToObject<string[]>(extensionLanguagesValue, []);
return JSON.stringify(
toUniqueLanguageCodes([...convertedSourceLanguages, ...convertedExtensionLanguages]),
);
},
},
],
keys: [{ oldKey: 'sourceLanguages', newKey: 'browseLanguages' }],
deleteKeys: ['sourceLanguages', 'extensionLanguages'],
},
];