immich/mobile/lib/providers/infrastructure/map.provider.dart
Adam Gastineau 225ca9ab8d
chore(mobile): use Drift @DriftAccessor() and collapse some providers (#30693)
* chore(mobile): use Drift @DriftAccessor() and collapse some providers

* Fix import order

* Required formatting
2026-08-17 14:43:32 -07:00

26 lines
1.1 KiB
Dart

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/domain/services/map.service.dart';
import 'package:immich_mobile/presentation/widgets/map/map.state.dart';
import 'package:immich_mobile/providers/infrastructure/db.provider.dart';
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
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');
}
final users = ref.watch(mapStateProvider).withPartners
? ref.watch(timelineUsersProvider).valueOrNull ?? [user.id]
: [user.id];
final mapFactory = MapFactory(mapRepository: ref.watch(driftProvider).mapRepository);
final mapService = mapFactory.remote(users, ref.watch(mapStateProvider).toOptions());
return mapService;
},
// Empty dependencies to inform the framework that this provider
// might be used in a ProviderScope
dependencies: const [],
);