Skip to content

Commit 80b581e

Browse files
authored
Fix custom EPUB reading order
1 parent a44f085 commit 80b581e

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file. Take a look
2929
#### Navigator
3030

3131
* PDF documents are now opened off the main thread, preventing UI freezes with large files.
32+
* Fixed providing a custom reading order to the `EPUBNavigatorViewController` (contributed by [@lbeus](https://github.com/readium/swift-toolkit/pull/694)).
3233

3334

3435
## [3.6.0]

Sources/Navigator/EPUB/EPUBNavigatorViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,15 @@ open class EPUBNavigatorViewController: InputObservableViewController,
296296

297297
let viewModel = try EPUBNavigatorViewModel(
298298
publication: publication,
299+
readingOrder: readingOrder ?? publication.readingOrder,
299300
config: config,
300301
httpServer: httpServer
301302
)
302303

303304
self.init(
304305
viewModel: viewModel,
305306
initialLocation: initialLocation,
306-
readingOrder: readingOrder ?? publication.readingOrder,
307+
readingOrder: viewModel.readingOrder,
307308
positionsByReadingOrder:
308309
// Positions and total progression only make sense in the context
309310
// of the publication's actual reading order. Therefore when

Sources/Navigator/EPUB/EPUBNavigatorViewModel.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ final class EPUBNavigatorViewModel: Loggable {
3838
/// `httpServer`. This is used to serve custom font files, for example.
3939
@Atomic private var servedFiles: [FileURL: HTTPURL] = [:]
4040

41-
var readingOrder: ReadingOrder { publication.readingOrder }
41+
let readingOrder: ReadingOrder
4242

4343
convenience init(
4444
publication: Publication,
45+
readingOrder: ReadingOrder,
4546
config: EPUBNavigatorViewController.Configuration,
4647
httpServer: HTTPServer
4748
) throws {
@@ -55,6 +56,7 @@ final class EPUBNavigatorViewModel: Loggable {
5556

5657
try self.init(
5758
publication: publication,
59+
readingOrder: readingOrder,
5860
config: config,
5961
httpServer: httpServer,
6062
publicationEndpoint: publicationEndpoint,
@@ -89,6 +91,7 @@ final class EPUBNavigatorViewModel: Loggable {
8991

9092
private init(
9193
publication: Publication,
94+
readingOrder: ReadingOrder,
9295
config: EPUBNavigatorViewController.Configuration,
9396
httpServer: HTTPServer?,
9497
publicationEndpoint: HTTPServerEndpoint?,
@@ -123,6 +126,7 @@ final class EPUBNavigatorViewModel: Loggable {
123126
}
124127

125128
self.publication = publication
129+
self.readingOrder = readingOrder
126130
self.config = config
127131
editingActions = EditingActionsController(
128132
actions: config.editingActions,

0 commit comments

Comments
 (0)