Skip to content

Commit 3ecc6fa

Browse files
authored
Various v3 fixes (#499)
1 parent ac1f0ed commit 3ecc6fa

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

Sources/LCP/License/LicenseValidation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ extension LicenseValidation {
320320
.map { $0.body ?? Data() }
321321
.get()
322322

323-
try await raise(.retrievedStatusData(data))
323+
try await raise(.retrievedLicenseData(data))
324324
}
325325

326326
private func checkLicenseStatus(of license: LicenseDocument, status: StatusDocument?, statusDocumentTakesPrecedence: Bool) async throws {

Sources/Navigator/Audiobook/AudioNavigator.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
314314
if let time = time {
315315
let locator = makeLocator(forTime: time)
316316
currentLocation = locator
317-
delegate?.navigator(self, locationDidChange: locator)
317+
Task { @MainActor in
318+
delegate?.navigator(self, locationDidChange: locator)
319+
}
318320
}
319321

320322
makePlaybackInfo(forTime: time) { info in
@@ -418,7 +420,9 @@ public final class AudioNavigator: Navigator, Configurable, AudioSessionUser, Lo
418420
await withCheckedContinuation { continuation in
419421
player.seek(to: CMTime(seconds: time, preferredTimescale: 1000)) { [weak self] finished in
420422
if let self = self, finished {
421-
self.delegate?.navigator(self, didJumpTo: locator)
423+
Task { @MainActor in
424+
self.delegate?.navigator(self, didJumpTo: locator)
425+
}
422426
}
423427
continuation.resume()
424428
}

Sources/Navigator/Audiobook/PublicationMediaLoader.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,17 @@ final class PublicationMediaLoader: NSObject, AVAssetResourceLoaderDelegate, Log
159159
range: range,
160160
consume: { dataRequest.respond(with: $0) }
161161
)
162-
switch result {
163-
case .success:
164-
request.finishLoading()
165-
case let .failure(error):
166-
request.finishLoading(with: error)
162+
163+
queue.async { [weak self] in
164+
switch result {
165+
case .success:
166+
request.finishLoading()
167+
case let .failure(error):
168+
request.finishLoading(with: error)
169+
}
170+
171+
self?.finishRequest(request)
167172
}
168-
self.finishRequest(request)
169173
}
170174

171175
registerRequest(request, task: task, for: link.url())

Sources/Navigator/EPUB/EPUBNavigatorViewController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,8 @@ extension EPUBNavigatorViewController: EPUBNavigatorViewModelDelegate {
902902

903903
func epubNavigatorViewModel(_ viewModel: EPUBNavigatorViewModel, runScript script: String, in scope: EPUBScriptScope) {
904904
Task {
905+
await initialized()
906+
905907
switch scope {
906908
case .currentResource:
907909
await (paginationView.currentView as? EPUBSpreadView)?.evaluateScript(script)

Sources/Navigator/Navigator.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ public struct NavigatorGoOptions {
6666
self.animated = animated
6767
otherOptionsJSON = JSONDictionary(otherOptions) ?? JSONDictionary()
6868
}
69+
70+
public static var none: NavigatorGoOptions {
71+
NavigatorGoOptions()
72+
}
73+
74+
/// Convenience helper for options that contain only animated: true.
75+
public static var animated: NavigatorGoOptions {
76+
NavigatorGoOptions(animated: true)
77+
}
6978
}
7079

7180
public extension Navigator {
@@ -110,7 +119,7 @@ public extension Navigator {
110119
}
111120
}
112121

113-
public protocol NavigatorDelegate: AnyObject {
122+
@MainActor public protocol NavigatorDelegate: AnyObject {
114123
/// Called when the current position in the publication changed. You should save the locator here to restore the
115124
/// last read page.
116125
func navigator(_ navigator: Navigator, locationDidChange locator: Locator)

0 commit comments

Comments
 (0)