2024-01-15 16:26:13 +01:00
|
|
|
import 'package:immich_mobile/mixins/error_logger.mixin.dart';
|
2024-05-01 04:36:40 +02:00
|
|
|
import 'package:immich_mobile/models/map/map_marker.model.dart';
|
2024-05-02 22:59:14 +02:00
|
|
|
import 'package:immich_mobile/services/api.service.dart';
|
2023-08-27 07:07:35 +02:00
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
|
2024-01-15 16:26:13 +01:00
|
|
|
class MapSerivce with ErrorLoggerMixin {
|
2023-08-27 07:07:35 +02:00
|
|
|
final ApiService _apiService;
|
2024-01-15 16:26:13 +01:00
|
|
|
@override
|
|
|
|
final logger = Logger("MapService");
|
2023-08-27 07:07:35 +02:00
|
|
|
|
2024-01-15 16:26:13 +01:00
|
|
|
MapSerivce(this._apiService);
|
2023-08-27 07:07:35 +02:00
|
|
|
|
2024-01-15 16:26:13 +01:00
|
|
|
Future<Iterable<MapMarker>> getMapMarkers({
|
2023-08-27 07:07:35 +02:00
|
|
|
bool? isFavorite,
|
2023-10-04 15:51:07 +02:00
|
|
|
bool? withArchived,
|
2024-04-06 16:04:40 +02:00
|
|
|
bool? withPartners,
|
2023-08-27 07:07:35 +02:00
|
|
|
DateTime? fileCreatedAfter,
|
|
|
|
DateTime? fileCreatedBefore,
|
|
|
|
}) async {
|
2024-01-15 16:26:13 +01:00
|
|
|
return logError(
|
|
|
|
() async {
|
2024-05-29 17:51:01 +02:00
|
|
|
final markers = await _apiService.mapApi.getMapMarkers(
|
2024-01-15 16:26:13 +01:00
|
|
|
isFavorite: isFavorite,
|
|
|
|
isArchived: withArchived,
|
2024-04-06 16:04:40 +02:00
|
|
|
withPartners: withPartners,
|
2024-01-15 16:26:13 +01:00
|
|
|
fileCreatedAfter: fileCreatedAfter,
|
|
|
|
fileCreatedBefore: fileCreatedBefore,
|
|
|
|
);
|
2023-08-27 07:07:35 +02:00
|
|
|
|
2024-01-15 16:26:13 +01:00
|
|
|
return markers?.map(MapMarker.fromDto) ?? [];
|
|
|
|
},
|
|
|
|
defaultValue: [],
|
2024-02-24 04:38:57 +01:00
|
|
|
errorMessage: "Failed to get map markers",
|
2024-01-15 16:26:13 +01:00
|
|
|
);
|
2023-08-27 07:07:35 +02:00
|
|
|
}
|
|
|
|
}
|