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() {