From 8768f2807312873551cde938593e7ca670a3320f Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Mon, 9 Jan 2023 18:52:33 +0100 Subject: [PATCH] Refresh notifications list on resume from background --- .../Sources/Notifications/NotificationsListView.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift index 5d015f8d..fa619884 100644 --- a/Packages/Notifications/Sources/Notifications/NotificationsListView.swift +++ b/Packages/Notifications/Sources/Notifications/NotificationsListView.swift @@ -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