diff --git a/CHANGELOG.md b/CHANGELOG.md index 0edf58f..4e2454f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,5 +95,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Sanitize malformed UTF-16 in user metadata to prevent rendering crashes [PR #234](https://github.com/marmot-protocol/whitenoise/pull/234) - Lock app orientation to portrait mode [PR #235](https://github.com/marmot-protocol/whitenoise/pull/235) - Fix camera permission flow [PR #194](https://github.com/marmot-protocol/sloth/pull/194) +- Fix notifications arriving on foreground after accepting invite [PR #361](https://github.com/marmot-protocol/whitenoise/pull/361) ### Security diff --git a/lib/hooks/use_active_chat.dart b/lib/hooks/use_active_chat.dart index abdb4f8..6ae8f9c 100644 --- a/lib/hooks/use_active_chat.dart +++ b/lib/hooks/use_active_chat.dart @@ -14,7 +14,7 @@ void useActiveChat({ setActiveChat(groupId); cancelGroupNotifications(groupId); }); - return () => Future.microtask(clearActiveChat); + return null; }, [groupId]); useOnAppLifecycleStateChange((previous, current) { diff --git a/test/hooks/use_active_chat_test.dart b/test/hooks/use_active_chat_test.dart index a62ca93..be8a38b 100644 --- a/test/hooks/use_active_chat_test.dart +++ b/test/hooks/use_active_chat_test.dart @@ -151,7 +151,9 @@ void main() { expect(cancelNotificationsCalls, ['group123']); }); - testWidgets('clears active chat on unmount', (tester) async { + testWidgets('does not clear active chat on unmount to prevent navigation race condition', ( + tester, + ) async { await mountHook(tester, () { useActiveChat( groupId: 'group123', @@ -169,7 +171,7 @@ void main() { await tester.pump(); expect(setActiveChatCalls, isEmpty); - expect(clearActiveChatCallCount, 1); + expect(clearActiveChatCallCount, 0); }); }); }