Skip to content

Commit

Permalink
Avoid stacking multiple game screens from notification open
Browse files Browse the repository at this point in the history
Closes #600
  • Loading branch information
veloce committed Apr 15, 2024
1 parent 1aedcba commit 6a6baea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,6 @@ class _EntryPointState extends ConsumerState<_EntryPointWidget> {
final RemoteMessage? initialMessage =
await FirebaseMessaging.instance.getInitialMessage();

// If the message also contains a data property with a "type" of "chat",
// navigate to a chat screen
if (initialMessage != null) {
_handleMessage(initialMessage);
}
Expand All @@ -300,6 +298,12 @@ class _EntryPointState extends ConsumerState<_EntryPointWidget> {
case 'gameFinish':
final gameFullId = message.data['lichess.fullId'] as String?;
if (gameFullId != null) {
// remove any existing routes before navigating to the game
// screen to avoid stacking multiple game screens
final navState = Navigator.of(context);
if (navState.canPop()) {
navState.popUntil((route) => route.isFirst);
}
pushPlatformRoute(
context,
rootNavigator: true,
Expand Down

0 comments on commit 6a6baea

Please sign in to comment.