From 502546eace2615988056d3d096e2fe07319c936d Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Tue, 26 Apr 2022 20:55:12 -0700 Subject: [PATCH] add second timer to dismiss snackbar in case the first fails --- .../Sources/App/Views/RootView/RootView.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift b/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift index b5cf7979c..fdb5533ee 100644 --- a/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/RootView/RootView.swift @@ -64,6 +64,16 @@ struct InnerRootView: View { isShowing: $viewModel.showSnackbar, text: Text(viewModel.snackbarMessage ?? "") ) + // Adding an extra dispatch to dismiss the snackbar since the internal timer sometimes fails + .onChange(of: viewModel.showSnackbar) { newValue in + if newValue { + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { + withAnimation { + viewModel.showSnackbar = false + } + } + } + } #if os(iOS) .customAlert(isPresented: $viewModel.showPushNotificationPrimer) { pushNotificationPrimerView