From dcad44218be6750c3b2bd7530cef4b85c85ad9e4 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sat, 9 May 2026 13:00:36 +0200 Subject: [PATCH] Fix setting invalid value for reader settings When changing a setting from DEFAULT to another value, the value was incorrectly wrapped in an array which lead to an invalid value to get set. This then caused an error to be thrown, making the reader unusable fixes #1099 --- CHANGELOG.md | 1 + src/base/components/buttons/ButtonSelect.tsx | 2 +- src/features/metadata/Metadata.constants.ts | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e635912f..2ea44108 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - (**Navigation**) Fix obsolete extensions being included in the updatable extensions info - (**Extensions**) Fix showing the uninstall button twice in the extension info page in case the extensions is obsolete and has a update at the same time +- (**Reader**) Fix changing reader layout settings from their default value to another causing the reader to break ## [20260508.01] (r3136) - 2026-05-08 diff --git a/src/base/components/buttons/ButtonSelect.tsx b/src/base/components/buttons/ButtonSelect.tsx index ced71ccb..3d6226f4 100644 --- a/src/base/components/buttons/ButtonSelect.tsx +++ b/src/base/components/buttons/ButtonSelect.tsx @@ -38,7 +38,7 @@ export const ButtonSelect = { if (value === undefined) { - return [displayValue]; + return isMultiSelect ? [displayValue] : displayValue; } if (isMultiSelect) { diff --git a/src/features/metadata/Metadata.constants.ts b/src/features/metadata/Metadata.constants.ts index 2089c5fb..4349eb99 100644 --- a/src/features/metadata/Metadata.constants.ts +++ b/src/features/metadata/Metadata.constants.ts @@ -31,6 +31,9 @@ import { detectLocale, getISOLanguage } from '@/lib/ISOLanguageUtil.ts'; import type { I18nResourceCode } from '@/i18n'; import { i18nResources } from '@/i18n'; import { toUniqueLanguageCodes } from '@/base/utils/Languages.ts'; +import { assertIsDefined } from '@/base/Asserts.ts'; + +const MATCH_ARRAY_NUMBERS = /^\[\d+(?:,\d+)*]$/g; export const APP_METADATA_KEY_PREFIX = 'webUI'; @@ -701,6 +704,22 @@ export const METADATA_MIGRATIONS: IMetadataMigration[] = [ keys: [{ oldKey: 'sourceLanguages', newKey: 'browseLanguages' }], deleteKeys: ['sourceLanguages', 'extensionLanguages'], }, + { + values: [ + ...(() => + ['pageScaleMode', 'readingDirection', 'readingMode', 'tapZoneLayout'].map((key) => ({ + key, + oldValue: MATCH_ARRAY_NUMBERS, + newValue: (value) => { + const array = jsonSaveParse(value); + + assertIsDefined(array); + + return JSON.stringify(array[0]); + }, + })) satisfies IMetadataMigration['values'])(), + ], + }, ]; export const ALL_APP_METADATA_KEY_PREFIXES: string[] = [