Skip to content

Make converting a Link to a Locator synchronous - #892

Merged
mickael-menu merged 1 commit into
developfrom
fix/locate-sync
Aug 28, 2026
Merged

Make converting a Link to a Locator synchronous#892
mickael-menu merged 1 commit into
developfrom
fix/locate-sync

Conversation

@mickael-menu

Copy link
Copy Markdown
Member

Changed

Shared

  • Converting a Link to a Locator is now synchronous: await publication.locate(link) becomes publication.locator(for: link). The logic moved to Manifest, so it is also available as manifest.locator(for: link) without a Publication.

This aligns the API with the Kotlin toolkit, and simplifies validating a Link in synchronous context (e.g. reacting to an input event).

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.

Pull request overview

This PR makes LinkLocator conversion synchronous by moving the logic into Manifest and exposing a new Publication.locator(for:) API, then updates navigators, the test app, and tests accordingly.

Changes:

  • Added Manifest.locator(for:) and Publication.locator(for:), and marked the old async locate(_ link:) APIs unavailable.
  • Updated Navigator/TestApp call sites to use publication.locator(for:) (and updated the EPUB viewport calculator fallback to use the manifest).
  • Updated/relocated tests (including migrating some suites from XCTest to Swift Testing) and added a changelog entry.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/SharedTests/Publication/Services/Locator/DefaultLocatorServiceTests.swift Removes tests for async locate(Link) since conversion moved out of the service.
Tests/SharedTests/Publication/PublicationTests.swift Migrates to Swift Testing and adds coverage for Publication.locator(for:).
Tests/SharedTests/Publication/ManifestTests.swift Migrates to Swift Testing and adds coverage for Manifest.locator(for:).
Tests/NavigatorTests/EPUB/EPUBViewportAndLocationCalculatorTests.swift Updates tests for sync compute() and manifest-based fallback locator construction.
TestApp/Sources/Reader/Common/VisualReaderViewController.swift Replaces await publication.locate(link) with publication.locator(for:) for image preview and page list logic.
TestApp/Sources/Reader/Common/Outline/OutlineTableView.swift Removes async Task wrapper by using synchronous publication.locator(for:).
Sources/Streamer/Parser/Audio/Services/AudioLocatorService.swift Drops the locate(Link) delegation path now that link→locator conversion is synchronous elsewhere.
Sources/Shared/Publication/Services/Locator/LocatorService.swift Removes locate(Link) from the service protocol and Publication helpers.
Sources/Shared/Publication/Services/Locator/DefaultLocatorService.swift Marks locate(Link) unavailable (guiding callers to Publication.locator(for:)).
Sources/Shared/Publication/Services/Content/Iterators/PublicationContentIterator.swift Removes awaiting link→locator conversion; uses the new synchronous API.
Sources/Shared/Publication/Publication.swift Adds locator(for:) and marks old locate(_ link:) unavailable/renamed.
Sources/Shared/Publication/Manifest.swift Implements the core synchronous locator(for:) conversion logic.
Sources/Navigator/PDF/PDFNavigatorViewController.swift Updates link navigation to use publication.locator(for:).
Sources/Navigator/EPUB/EPUBViewportAndLocationCalculator.swift Makes compute() synchronous, adds manifest parameter, and builds fallback locators via manifest.locator(for:).
Sources/Navigator/EPUB/EPUBNavigatorViewController.swift Wires the new compute() signature and uses publication.locator(for:) for link navigation.
Sources/Navigator/Audiobook/AudioNavigator.swift Updates link navigation to use publication.locator(for:).
CHANGELOG.md Documents the API change from await publication.locate(link) to publication.locator(for: link).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Sources/Navigator/EPUB/EPUBNavigatorViewController.swift
Comment thread Sources/Shared/Publication/Services/Locator/LocatorService.swift
@mickael-menu
mickael-menu merged commit dcca0e9 into develop Aug 28, 2026
6 checks passed
@mickael-menu
mickael-menu deleted the fix/locate-sync branch August 28, 2026 10:13
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