From 0bbf1d8483f1de9f294eaca5301fbdb57298fc5d Mon Sep 17 00:00:00 2001 From: Triin <87473353+triin-ko@users.noreply.github.com> Date: Tue, 20 Jun 2023 16:55:52 +0300 Subject: [PATCH 1/2] Reload spread if Webview is terminated --- Sources/Navigator/EPUB/EPUBNavigatorViewController.swift | 4 ++++ Sources/Navigator/EPUB/EPUBSpreadView.swift | 7 +++++++ 2 files changed, 11 insertions(+) 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 { From 02cded33430cdc93aa12f0bf6e279116bdd131d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mickae=CC=88l=20Menu?= Date: Mon, 26 Jun 2023 09:41:10 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0765988f..f5b399ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ All notable changes to this project will be documented in this file. Take a look * The `WKWebView` is now inspectable again with Safari starting from iOS 16.4. * 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. +* [#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]