mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
fix(mobile): Prevents duplicate taps navigating to the same route twice (#1855)
This commit is contained in:
17
mobile/lib/routing/duplicate_guard.dart
Normal file
17
mobile/lib/routing/duplicate_guard.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// Guards against duplicate navigation to this route
|
||||
class DuplicateGuard extends AutoRouteGuard {
|
||||
DuplicateGuard();
|
||||
@override
|
||||
void onNavigation(NavigationResolver resolver, StackRouter router) async {
|
||||
// Duplicate navigation
|
||||
if (resolver.route.name == router.current.name) {
|
||||
debugPrint('DuplicateGuard: Preventing duplicate route navigation for ${resolver.route.name}');
|
||||
resolver.next(false);
|
||||
} else {
|
||||
resolver.next(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user