Skip to content

Make the navigator preferences no longer Codable - #950

Merged
mickael-menu merged 2 commits into
developfrom
fix/preferences-non-codable
Nov 26, 2026
Merged

mickael-menu merged 2 commits into
developfrom
fix/preferences-non-codable

Conversation

@mickael-menu

Copy link
Copy Markdown
Member

EPUBPreferences, PDFPreferences and AudioPreferences were Codable, 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 Preferences from it before submitting them to the navigator.

Toolkit

  • New LegacyEPUBPreferences, LegacyPDFPreferences and LegacyAudioPreferences decode the preferences persisted with Readium 3.x, so apps can map them to their own model:
    • They are self-contained snapshots of the 3.x types, with the values as they were saved, including the removed EPUB preferences (theme, publisherStyles, imageFilter, typeScale).

Test App

  • New EPUBUserSettings, PDFUserSettings and AudioUserSettings models mirror the preferences of each navigator. The EPUB colors are stored as a theme.
  • Existing Test App installs must be reinstalled, as the database schema changed.

Docs

  • The Preferences guide explains how to persist an app-owned settings model and lists the preferences specific to a publication.
  • The migration guide explains how to migrate the 3.x preferences with the Legacy*Preferences types, and how the removed EPUB preferences map to the new ones.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread docs/Guides/Navigator/Preferences.md Resolved
Comment thread docs/Guides/Navigator/Preferences.md Resolved
@mickael-menu
mickael-menu merged commit 3b7c3e0 into develop Nov 26, 2026
5 checks passed
@mickael-menu
mickael-menu deleted the fix/preferences-non-codable branch November 26, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants