You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-08 23:07:06 +02:00
fix(mobile): deeplinking to asset view while viewer is already open (#19812)
* initial attempt at new guard * do not resolve the route when replaced * Update gallery_guard.dart comment --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
31
mobile/lib/routing/gallery_guard.dart
Normal file
31
mobile/lib/routing/gallery_guard.dart
Normal file
@ -0,0 +1,31 @@
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
|
||||
/// Handles duplicate navigation to this route (primarily for deep linking)
|
||||
class GalleryGuard extends AutoRouteGuard {
|
||||
const GalleryGuard();
|
||||
@override
|
||||
void onNavigation(NavigationResolver resolver, StackRouter router) async {
|
||||
final newRouteName = resolver.route.name;
|
||||
final currentTopRouteName =
|
||||
router.stack.isNotEmpty ? router.stack.last.name : null;
|
||||
|
||||
if (currentTopRouteName == newRouteName) {
|
||||
// Replace instead of pushing duplicate
|
||||
final args = resolver.route.args as GalleryViewerRouteArgs;
|
||||
|
||||
router.replace(
|
||||
GalleryViewerRoute(
|
||||
renderList: args.renderList,
|
||||
initialIndex: args.initialIndex,
|
||||
heroOffset: args.heroOffset,
|
||||
showStack: args.showStack,
|
||||
),
|
||||
);
|
||||
// Prevent further navigation since we replaced the route
|
||||
resolver.next(false);
|
||||
return;
|
||||
}
|
||||
resolver.next(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user