From 63c77b067a00418c866bd9034cb433ff44b3b9e6 Mon Sep 17 00:00:00 2001 From: avashilling <165050625+avashilling@users.noreply.github.com> Date: Tue, 29 Jul 2025 09:12:40 -0400 Subject: [PATCH] fix: construct banner always does cleanup on close (#3573) --- .../chat/utils/unlocked_morphs_snackbar.dart | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/pangea/chat/utils/unlocked_morphs_snackbar.dart b/lib/pangea/chat/utils/unlocked_morphs_snackbar.dart index f8ae1d70c..8239f37c5 100644 --- a/lib/pangea/chat/utils/unlocked_morphs_snackbar.dart +++ b/lib/pangea/chat/utils/unlocked_morphs_snackbar.dart @@ -32,12 +32,14 @@ class ConstructNotificationUtil { } } + static final Set _closedOverlays = {}; + static void onClose(ConstructIdentifier construct) { final overlayKey = "${construct.string}_snackbar"; + if (_closedOverlays.contains(overlayKey)) return; + _closedOverlays.add(overlayKey); MatrixState.pAnyState.closeOverlay(overlayKey); - MatrixState.pAnyState.activeOverlays.remove(overlayKey); - unlockedConstructs.remove(construct); closeCompleter?.complete(); closeCompleter = null; @@ -147,14 +149,20 @@ class ConstructNotificationOverlayState @override void dispose() { + ConstructNotificationUtil.onClose(widget.construct); _controller?.dispose(); super.dispose(); } void _close() { - _controller?.reverse().then((_) { + if (_controller?.status == AnimationStatus.completed) { + //only animate closed if still mounted, not if navigating away + _controller?.reverse().then((_) { + ConstructNotificationUtil.onClose(widget.construct); + }); + } else { ConstructNotificationUtil.onClose(widget.construct); - }); + } } void _showDetails() {