Refresh notifications list on resume from background

This commit is contained in:
Thomas Ricouard 2023-01-09 18:52:33 +01:00
parent 70f60ee977
commit 8768f28073

View file

@ -6,6 +6,7 @@ import DesignSystem
import Env
public struct NotificationsListView: View {
@Environment(\.scenePhase) private var scenePhase
@EnvironmentObject private var theme: Theme
@EnvironmentObject private var watcher: StreamWatcher
@EnvironmentObject private var client: Client
@ -59,6 +60,16 @@ public struct NotificationsListView: View {
viewModel.handleEvent(event: latestEvent)
}
})
.onChange(of: scenePhase, perform: { scenePhase in
switch scenePhase {
case .active:
Task {
await viewModel.fetchNotifications()
}
default:
break
}
})
}
@ViewBuilder