From 9519cffe02e63d5c77447a8cd30ab7284914304a Mon Sep 17 00:00:00 2001 From: Leonard Beus Date: Thu, 15 Jan 2026 08:57:02 +0100 Subject: [PATCH 1/2] Fix reading order not synced between EPUBNavigatorViewController and EPUBNavigatorViewModel --- Sources/Navigator/EPUB/EPUBNavigatorViewController.swift | 1 + Sources/Navigator/EPUB/EPUBNavigatorViewModel.swift | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift b/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift index 60a9ccf8e..cea49ce62 100644 --- a/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift +++ b/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift @@ -296,6 +296,7 @@ open class EPUBNavigatorViewController: InputObservableViewController, let viewModel = try EPUBNavigatorViewModel( publication: publication, + readingOrder: readingOrder ?? publication.readingOrder, config: config, httpServer: httpServer ) diff --git a/Sources/Navigator/EPUB/EPUBNavigatorViewModel.swift b/Sources/Navigator/EPUB/EPUBNavigatorViewModel.swift index 68440246a..c0db2b036 100644 --- a/Sources/Navigator/EPUB/EPUBNavigatorViewModel.swift +++ b/Sources/Navigator/EPUB/EPUBNavigatorViewModel.swift @@ -38,10 +38,11 @@ final class EPUBNavigatorViewModel: Loggable { /// `httpServer`. This is used to serve custom font files, for example. @Atomic private var servedFiles: [FileURL: HTTPURL] = [:] - var readingOrder: ReadingOrder { publication.readingOrder } + let readingOrder: ReadingOrder convenience init( publication: Publication, + readingOrder: ReadingOrder, config: EPUBNavigatorViewController.Configuration, httpServer: HTTPServer ) throws { @@ -55,6 +56,7 @@ final class EPUBNavigatorViewModel: Loggable { try self.init( publication: publication, + readingOrder: readingOrder, config: config, httpServer: httpServer, publicationEndpoint: publicationEndpoint, @@ -89,6 +91,7 @@ final class EPUBNavigatorViewModel: Loggable { private init( publication: Publication, + readingOrder: ReadingOrder, config: EPUBNavigatorViewController.Configuration, httpServer: HTTPServer?, publicationEndpoint: HTTPServerEndpoint?, @@ -123,6 +126,7 @@ final class EPUBNavigatorViewModel: Loggable { } self.publication = publication + self.readingOrder = readingOrder self.config = config editingActions = EditingActionsController( actions: config.editingActions, From ac1590454dba634385c67130a2c5e5b8cfd7e1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Thu, 15 Jan 2026 17:18:40 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + Sources/Navigator/EPUB/EPUBNavigatorViewController.swift | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92bb29ac5..78fe83668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file. Take a look #### Navigator * PDF documents are now opened off the main thread, preventing UI freezes with large files. +* Fixed providing a custom reading order to the `EPUBNavigatorViewController` (contributed by [@lbeus](https://github.com/readium/swift-toolkit/pull/694)). ## [3.6.0] diff --git a/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift b/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift index cea49ce62..382a08083 100644 --- a/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift +++ b/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift @@ -304,7 +304,7 @@ open class EPUBNavigatorViewController: InputObservableViewController, self.init( viewModel: viewModel, initialLocation: initialLocation, - readingOrder: readingOrder ?? publication.readingOrder, + readingOrder: viewModel.readingOrder, positionsByReadingOrder: // Positions and total progression only make sense in the context // of the publication's actual reading order. Therefore when