Skip to content

Commit f47fafa

Browse files
authored
Reload spreads when the WebView is terminated (#311)
1 parent b80781a commit f47fafa

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ All notable changes to this project will be documented in this file. Take a look
2626
* Fixed crash in the `PublicationSpeechSynthesizer` when closing the navigator without stopping it first.
2727
* Fixed the audio session kept opened while the app is in the background and paused.
2828
* Fixed the **Attribute dir redefined** error when the EPUB resource already has a `dir` attribute.
29+
* [#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)).
30+
2931

3032
## [2.5.0]
3133

Sources/Navigator/EPUB/EPUBNavigatorViewController.swift

+4
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,10 @@ extension EPUBNavigatorViewController: EPUBSpreadViewDelegate {
10521052
func spreadView(_ spreadView: EPUBSpreadView, present viewController: UIViewController) {
10531053
present(viewController, animated: true)
10541054
}
1055+
1056+
func spreadViewDidTerminate() {
1057+
reloadSpreads(force: true)
1058+
}
10551059
}
10561060

10571061
extension EPUBNavigatorViewController: EditingActionsControllerDelegate {

Sources/Navigator/EPUB/EPUBSpreadView.swift

+7
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ protocol EPUBSpreadViewDelegate: AnyObject {
3838

3939
/// Called when the user released a key and it was not handled by the resource.
4040
func spreadView(_ spreadView: EPUBSpreadView, didReleaseKey event: KeyEvent)
41+
42+
/// Called when WKWebview terminates
43+
func spreadViewDidTerminate()
4144
}
4245

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

469472
decisionHandler(policy)
470473
}
474+
475+
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
476+
delegate?.spreadViewDidTerminate()
477+
}
471478
}
472479

473480
extension EPUBSpreadView: UIScrollViewDelegate {

0 commit comments

Comments
 (0)