Skip to content

Commit

Permalink
save webview state on both new tab and tabs list open
Browse files Browse the repository at this point in the history
  • Loading branch information
svojsu committed Nov 11, 2024
1 parent ead20fc commit 3d835a1
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions novawallet/Modules/DApp/DAppBrowser/DAppBrowserPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ final class DAppBrowserPresenter {

view?.didSet(canShowSettings: canShowSettings)
}

private func saveCurrentWebViewState() {
if
let currentTabId,
let currentWebView = webViewPool.getWebView(for: currentTabId),
let url = currentWebView.url {
if #available(iOS 15.0, *) {
let currentWebViewState = currentWebView.interactionState
tabsManager.updateStateForTab(with: url, currentWebViewState)
} else {
// Fallback on earlier versions
}
}
}
}

extension DAppBrowserPresenter: DAppBrowserPresenterProtocol {
Expand Down Expand Up @@ -114,20 +128,10 @@ extension DAppBrowserPresenter: DAppBrowserPresenterProtocol {
return
}

if
let currentTabId,
let currentWebView = webViewPool.getWebView(for: currentTabId),
let url = currentWebView.url {
if #available(iOS 15.0, *) {
let currentWebViewState = currentWebView.interactionState
tabsManager.updateStateForTab(with: url, currentWebViewState)
} else {
// Fallback on earlier versions
}
}

let webView = webViewPool.setupWebView(for: tab.uuid)

saveCurrentWebViewState()

let viewModel = DAppBrowserTabViewModel(
tab: tab,
loadRequired: false,
Expand Down Expand Up @@ -181,6 +185,8 @@ extension DAppBrowserPresenter: DAppBrowserInteractorOutputProtocol {
webView: webView
)

saveCurrentWebViewState()

currentTabId = tab.uuid

view?.didReceiveTab(viewModel: viewModel)
Expand Down

0 comments on commit 3d835a1

Please sign in to comment.