Repository navigation
Make the navigator preferences no longer Codable - #950
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The settings example has circular initialization and does not map the included sepia theme to sepia colors when restoring preferences.
2 open issues
What changed in this PR
This PR separates navigator inputs from persistent app settings in the Readium Swift toolkit, making apps responsible for their storage models and migrations.
Changes:
- Removes
Codable, merging, and filtering APIs from navigator preferences; adds legacy decoders for Readium 3.x data. - Migrates the Test App to app-owned settings models and storage.
- Updates tests, persistence guidance, and migration documentation.
| File | Description |
|---|---|
| Tests/NavigatorTests/Preferences/LegacyPreferencesTests.swift | Tests legacy decoding and invalid-value handling. |
| Tests/NavigatorTests/EPUB/Preferences/EPUBPreferencesTests.swift | Removes obsolete serialization tests and adapts fixtures. |
| TestApp/Sources/Reader/PDF/PDFViewController.swift | Uses the PDF settings store. |
| TestApp/Sources/Reader/PDF/PDFModule.swift | Derives initial PDF preferences from settings. |
| TestApp/Sources/Reader/EPUB/EPUBViewController.swift | Uses the EPUB settings store. |
| TestApp/Sources/Reader/EPUB/EPUBModule.swift | Derives initial EPUB preferences from settings. |
| TestApp/Sources/Reader/Common/Preferences/UserSettings.swift | Adds app-owned settings models and preference conversions. |
| TestApp/Sources/Reader/Common/Preferences/UserPreferences.swift | Connects preference editing to settings persistence. |
| TestApp/Sources/Reader/Audiobook/AudiobookViewController.swift | Uses the audio settings store. |
| TestApp/Sources/Reader/Audiobook/AudiobookModule.swift | Derives initial audio preferences from settings. |
| TestApp/Sources/Data/UserSettingsStore.swift | Stores and observes book-specific and shared settings. |
| TestApp/Sources/Data/UserPreferencesStore.swift | Removes the previous preference-storage abstraction. |
| TestApp/Sources/Data/Database.swift | Renames the settings storage column. |
| TestApp/Sources/Data/Book.swift | Adapts book persistence to app-owned settings. |
| Sources/Navigator/Preferences/Types.swift | Removes Codable from preference value types. |
| Sources/Navigator/Preferences/LenientDecoding.swift | Extracts the shared lenient-decoding helper. |
| Sources/Navigator/Preferences/Configurable.swift | Removes serialization and merging requirements. |
| Sources/Navigator/PDF/Preferences/PDFPreferences.swift | Adds legacy PDF decoding and retires filtering APIs. |
| Sources/Navigator/EPUB/Preferences/EPUBPreferences+Legacy.swift | Adds a self-contained EPUB 3.x snapshot decoder. |
| Sources/Navigator/EPUB/Preferences/EPUBPreferences.swift | Removes serialization, merging, and filtering implementations. |
| Sources/Navigator/Audiobook/Preferences/AudioPreferences.swift | Adds legacy audio decoding and retires storage helpers. |
| docs/Migration Guide.md | Explains app-owned settings and legacy preference migration. |
| docs/Guides/Navigator/Preferences.md | Demonstrates settings persistence and per-publication storage. |
| CHANGELOG.md | Records removal of preference serialization support. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

EPUBPreferences,PDFPreferencesandAudioPreferenceswereCodable, which made them a storage format: every change to a preference became a data migration. It also pushed apps to persist low-level navigator inputs instead of their own settings, which rarely map 1-1 (themes, a dual-page toggle).Apps now own their settings model, persist it the way they want, and derive the
Preferencesfrom it before submitting them to the navigator.Toolkit
LegacyEPUBPreferences,LegacyPDFPreferencesandLegacyAudioPreferencesdecode the preferences persisted with Readium 3.x, so apps can map them to their own model:theme,publisherStyles,imageFilter,typeScale).Test App
EPUBUserSettings,PDFUserSettingsandAudioUserSettingsmodels mirror the preferences of each navigator. The EPUB colors are stored as a theme.Docs
Legacy*Preferencestypes, and how the removed EPUB preferences map to the new ones.