2025-08-06 11:05:49 -04:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2026-01-23 03:21:48 +05:30
|
|
|
import 'package:immich_mobile/domain/services/map.service.dart';
|
|
|
|
|
import 'package:immich_mobile/presentation/widgets/map/map.state.dart';
|
2025-08-06 11:05:49 -04:00
|
|
|
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
|
2026-01-23 03:21:48 +05:30
|
|
|
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
|
2025-08-06 11:05:49 -04:00
|
|
|
import 'package:immich_mobile/providers/user.provider.dart';
|
|
|
|
|
|
|
|
|
|
final mapServiceProvider = Provider<MapService>(
|
|
|
|
|
(ref) {
|
|
|
|
|
final user = ref.watch(currentUserProvider);
|
|
|
|
|
if (user == null) {
|
|
|
|
|
throw Exception('User must be logged in to access map');
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-23 03:21:48 +05:30
|
|
|
final users = ref.watch(mapStateProvider).withPartners
|
|
|
|
|
? ref.watch(timelineUsersProvider).valueOrNull ?? [user.id]
|
|
|
|
|
: [user.id];
|
|
|
|
|
|
2026-08-17 14:43:32 -07:00
|
|
|
final mapFactory = MapFactory(mapRepository: ref.watch(driftProvider).mapRepository);
|
|
|
|
|
final mapService = mapFactory.remote(users, ref.watch(mapStateProvider).toOptions());
|
2025-08-06 11:05:49 -04:00
|
|
|
return mapService;
|
|
|
|
|
},
|
|
|
|
|
// Empty dependencies to inform the framework that this provider
|
|
|
|
|
// might be used in a ProviderScope
|
|
|
|
|
dependencies: const [],
|
|
|
|
|
);
|