mirror of
https://github.com/yattee/yattee.git
synced 2026-04-09 17:16:57 +00:00
Fix Home view showing zero counts after returning from background
onAppear only fires once when the view first appears, not on foreground return. Add scenePhase observer to reload data when the app becomes active.
This commit is contained in:
@@ -9,6 +9,7 @@ import SwiftUI
|
||||
|
||||
struct HomeView: View {
|
||||
@Environment(\.appEnvironment) private var appEnvironment
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
@Namespace private var sheetTransition
|
||||
@State private var playlists: [LocalPlaylist] = []
|
||||
@State private var bookmarksCount: Int = 0
|
||||
@@ -117,6 +118,11 @@ struct HomeView: View {
|
||||
.onAppear {
|
||||
loadData()
|
||||
}
|
||||
.onChange(of: scenePhase) { _, newPhase in
|
||||
if newPhase == .active {
|
||||
loadData()
|
||||
}
|
||||
}
|
||||
.task {
|
||||
await feedCache.loadFromDiskIfNeeded()
|
||||
await appEnvironment?.homeInstanceCache.loadFromDiskIfNeeded()
|
||||
|
||||
Reference in New Issue
Block a user