2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-27 21:16:48 +00:00

Prevent notification dismissal from ocurring multiple times (#435)

This commit is contained in:
Oliver 2023-10-23 21:37:33 +11:00 committed by GitHub
parent 76b6191a67
commit 8f1cd1cae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,6 +23,8 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
List<InvenTreeNotification> notifications = [];
bool isDismissing = false;
@override
String getAppBarTitle() => L10().notifications;
@ -45,10 +47,23 @@ class _NotificationState extends RefreshableState<NotificationWidget> {
*/
Future<void> 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<NotificationWidget> {
subtitle: Text(notification.message),
trailing: IconButton(
icon: FaIcon(FontAwesomeIcons.bookmark),
onPressed: () async {
onPressed: isDismissing ? null : () async {
dismissNotification(context, notification);
},
),