From 8f1cd1cae1b479ac813c6fd749d8dcee8019f1dc Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 23 Oct 2023 21:37:33 +1100 Subject: [PATCH] Prevent notification dismissal from ocurring multiple times (#435) --- lib/widget/notifications.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/widget/notifications.dart b/lib/widget/notifications.dart index 966890cc..4c342038 100644 --- a/lib/widget/notifications.dart +++ b/lib/widget/notifications.dart @@ -23,6 +23,8 @@ class _NotificationState extends RefreshableState { List notifications = []; + bool isDismissing = false; + @override String getAppBarTitle() => L10().notifications; @@ -45,10 +47,23 @@ class _NotificationState extends RefreshableState { */ Future dismissNotification(BuildContext context, InvenTreeNotification notification) async { + if (mounted) { + setState(() { + isDismissing = true; + }); + } else { + return; + } + await notification.dismiss(); - refresh(context); + if (mounted) { + refresh(context); + setState(() { + isDismissing = false; + }); + } } /* @@ -77,7 +92,7 @@ class _NotificationState extends RefreshableState { subtitle: Text(notification.message), trailing: IconButton( icon: FaIcon(FontAwesomeIcons.bookmark), - onPressed: () async { + onPressed: isDismissing ? null : () async { dismissNotification(context, notification); }, ),