Skip to content

Commit b621410

Browse files
authored
Add updateDatabaseAndPanels call on viewDidAppear (#4229)
Introduces updateDatabaseAndPanels, which updates the app database and panels for the current server. This method is now called in viewDidAppear and after certain actions to ensure data is refreshed without blocking app launch. <!-- Thank you for submitting a Pull Request and helping to improve Home Assistant. Please complete the following sections to help the processing and review of your changes. Please do not delete anything from this template. --> ## Summary <!-- Provide a brief summary of the changes you have made and most importantly what they aim to achieve --> ## Screenshots <!-- If this is a user-facing change not in the frontend, please include screenshots in light and dark mode. --> ## Link to pull request in Documentation repository <!-- Pull requests that add, change or remove functionality must have a corresponding pull request in the Companion App Documentation repository (https://github.com/home-assistant/companion.home-assistant). Please add the number of this pull request after the "#" --> Documentation: home-assistant/companion.home-assistant# ## Any other notes <!-- If there is any other information of note, like if this Pull Request is part of a bigger change, please include it here. -->
1 parent de371a6 commit b621410

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/App/WebView/WebViewController.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg
271271
loadActiveURLIfNeeded()
272272
}
273273

274+
override func viewDidAppear(_ animated: Bool) {
275+
super.viewDidAppear(animated)
276+
updateDatabaseAndPanels()
277+
}
278+
274279
override func viewWillDisappear(_ animated: Bool) {
275280
userActivity?.resignCurrent()
276281
}
@@ -740,7 +745,11 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg
740745
DispatchQueue.main.async { [self] in
741746
loadActiveURLIfNeeded()
742747
}
748+
}
743749

750+
/// Updates the app database and panels for the current server
751+
/// Called after view appears and on pull to refresh to avoid blocking app launch
752+
private func updateDatabaseAndPanels() {
744753
Task {
745754
await Current.appDatabaseUpdater.update(server: server)
746755
Current.panelsUpdater.update()
@@ -1545,5 +1554,6 @@ extension WebViewController: WebViewControllerProtocol {
15451554
showNoActiveURLError()
15461555
}
15471556
}
1557+
updateDatabaseAndPanels()
15481558
}
15491559
}

0 commit comments

Comments
 (0)