Handle missing reader keybinds in metadata

The current default value fallback logic for metadata just checks if a key is missing, or if it's value is undefined.
Since the keybinds are an object, a keybind that got newly added and wasn't saved to the metadata was never added with its default value to the object due to the metadata containing a "keybinds" key with an existing value
This commit is contained in:
schroda
2024-12-12 23:38:21 +01:00
parent d00c930598
commit 66b3757b12

View File

@@ -131,8 +131,11 @@ const convertMetadataToSettings = (
profiles.includes(profile) ? profile : DEFAULT_READER_PROFILE,
]),
) as IReaderSettings['readingModesDefaultProfile'],
hotkeys:
jsonSaveParse<IReaderSettings['hotkeys']>((metadata.hotkeys as string) ?? '') ?? defaultSettings.hotkeys,
hotkeys: {
...defaultSettings.hotkeys,
...(jsonSaveParse<IReaderSettings['hotkeys']>((metadata.hotkeys as string) ?? '') ??
defaultSettings.hotkeys),
},
};
};