diff --git a/CHANGELOG.md b/CHANGELOG.md index a71bfea3c..baf885275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift b/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift index 7e4ea3f3c..3d167ba14 100644 --- a/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift +++ b/Sources/Navigator/EPUB/EPUBNavigatorViewController.swift @@ -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 { diff --git a/Sources/Navigator/EPUB/EPUBSpreadView.swift b/Sources/Navigator/EPUB/EPUBSpreadView.swift index ca70a361a..1f3827962 100644 --- a/Sources/Navigator/EPUB/EPUBSpreadView.swift +++ b/Sources/Navigator/EPUB/EPUBSpreadView.swift @@ -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 {