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