2022-03-16 17:19:31 +02:00
|
|
|
import 'package:auto_route/auto_route.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2022-08-03 07:04:34 +02:00
|
|
|
import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
2023-06-27 23:00:20 +02:00
|
|
|
import 'package:immich_mobile/modules/memories/providers/memory.provider.dart';
|
2023-06-23 17:44:02 +02:00
|
|
|
import 'package:immich_mobile/modules/search/providers/people.provider.dart';
|
2022-03-16 17:19:31 +02:00
|
|
|
|
|
|
|
import 'package:immich_mobile/modules/search/providers/search_page_state.provider.dart';
|
2022-08-03 07:04:34 +02:00
|
|
|
import 'package:immich_mobile/modules/album/providers/shared_album.provider.dart';
|
2022-03-22 08:22:04 +02:00
|
|
|
import 'package:immich_mobile/shared/providers/server_info.provider.dart';
|
2022-03-16 17:19:31 +02:00
|
|
|
|
|
|
|
class TabNavigationObserver extends AutoRouterObserver {
|
|
|
|
/// Riverpod Instance
|
|
|
|
final WidgetRef ref;
|
|
|
|
|
|
|
|
TabNavigationObserver({
|
|
|
|
required this.ref,
|
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
|
|
|
void didInitTabRoute(TabPageRoute route, TabPageRoute? previousRoute) {
|
|
|
|
// Perform tasks on first navigation to SearchRoute
|
|
|
|
if (route.name == 'SearchRoute') {
|
|
|
|
// ref.refresh(getCuratedLocationProvider);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2022-04-24 04:08:45 +02:00
|
|
|
Future<void> didChangeTabRoute(
|
2022-07-13 14:23:48 +02:00
|
|
|
TabPageRoute route,
|
|
|
|
TabPageRoute previousRoute,
|
|
|
|
) async {
|
2022-03-16 17:19:31 +02:00
|
|
|
// Perform tasks on re-visit to SearchRoute
|
|
|
|
if (route.name == 'SearchRoute') {
|
|
|
|
// Refresh Location State
|
2023-01-26 16:40:19 +02:00
|
|
|
ref.invalidate(getCuratedLocationProvider);
|
|
|
|
ref.invalidate(getCuratedObjectProvider);
|
2023-06-23 17:44:02 +02:00
|
|
|
ref.invalidate(getCuratedPeopleProvider);
|
2022-03-16 17:19:31 +02:00
|
|
|
}
|
2022-03-22 08:22:04 +02:00
|
|
|
|
2022-04-24 04:08:45 +02:00
|
|
|
if (route.name == 'SharingRoute') {
|
|
|
|
ref.read(sharedAlbumProvider.notifier).getAllSharedAlbums();
|
|
|
|
}
|
|
|
|
|
2022-08-03 07:04:34 +02:00
|
|
|
if (route.name == 'LibraryRoute') {
|
|
|
|
ref.read(albumProvider.notifier).getAllAlbums();
|
|
|
|
}
|
2023-06-27 23:00:20 +02:00
|
|
|
|
|
|
|
if (route.name == 'HomeRoute') {
|
|
|
|
ref.invalidate(memoryFutureProvider);
|
|
|
|
}
|
2022-03-22 08:22:04 +02:00
|
|
|
ref.watch(serverInfoProvider.notifier).getServerVersion();
|
2022-03-16 17:19:31 +02:00
|
|
|
}
|
|
|
|
}
|