Skip to content

Reload spread if Webview is terminated #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@ All notable changes to this project will be documented in this file. Take a look
* Fixed crash in the `PublicationSpeechSynthesizer` when closing the navigator without stopping it first.
* Fixed the audio session kept opened while the app is in the background and paused.
* Fixed the **Attribute dir redefined** error when the EPUB resource already has a `dir` attribute.
* [#309](https://github.com/readium/swift-toolkit/issues/309) Fixed restoring the EPUB location when the application was killed in the background (contributed by [@triin-ko](https://github.com/readium/swift-toolkit/pull/311)).


## [2.5.0]

4 changes: 4 additions & 0 deletions Sources/Navigator/EPUB/EPUBNavigatorViewController.swift
Original file line number Diff line number Diff line change
@@ -1052,6 +1052,10 @@ extension EPUBNavigatorViewController: EPUBSpreadViewDelegate {
func spreadView(_ spreadView: EPUBSpreadView, present viewController: UIViewController) {
present(viewController, animated: true)
}

func spreadViewDidTerminate() {
reloadSpreads(force: true)
}
}

extension EPUBNavigatorViewController: EditingActionsControllerDelegate {
7 changes: 7 additions & 0 deletions Sources/Navigator/EPUB/EPUBSpreadView.swift
Original file line number Diff line number Diff line change
@@ -38,6 +38,9 @@ protocol EPUBSpreadViewDelegate: AnyObject {

/// Called when the user released a key and it was not handled by the resource.
func spreadView(_ spreadView: EPUBSpreadView, didReleaseKey event: KeyEvent)

/// Called when WKWebview terminates
func spreadViewDidTerminate()
}

class EPUBSpreadView: UIView, Loggable, PageView {
@@ -468,6 +471,10 @@ extension EPUBSpreadView: WKNavigationDelegate {

decisionHandler(policy)
}

func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
delegate?.spreadViewDidTerminate()
}
}

extension EPUBSpreadView: UIScrollViewDelegate {