1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-17 12:22:31 +02:00
immich/mobile/lib/modules/map/providers/map_marker.provider.dart
Stefan H ab97f03cb5
feat(mobile): include partner's photos on map (#8553)
* add option for showing partner images on the map

* renaming of iswithPartners variable
2024-04-06 14:04:40 +00:00

43 lines
1.1 KiB
Dart

import 'package:immich_mobile/modules/map/models/map_marker.dart';
import 'package:immich_mobile/modules/map/providers/map_service.provider.dart';
import 'package:immich_mobile/modules/map/providers/map_state.provider.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'map_marker.provider.g.dart';
@riverpod
Future<List<MapMarker>> mapMarkers(MapMarkersRef ref) async {
final service = ref.read(mapServiceProvider);
final mapState = ref.read(mapStateNotifierProvider);
DateTime? fileCreatedAfter;
bool? isFavorite;
bool? isIncludeArchived;
bool? isWithPartners;
if (mapState.relativeTime != 0) {
fileCreatedAfter =
DateTime.now().subtract(Duration(days: mapState.relativeTime));
}
if (mapState.showFavoriteOnly) {
isFavorite = true;
}
if (!mapState.includeArchived) {
isIncludeArchived = false;
}
if (mapState.withPartners) {
isWithPartners = true;
}
final markers = await service.getMapMarkers(
isFavorite: isFavorite,
withArchived: isIncludeArchived,
withPartners: isWithPartners,
fileCreatedAfter: fileCreatedAfter,
);
return markers.toList();
}