mirror of
https://github.com/immich-app/immich.git
synced 2024-12-19 00:32:49 +02:00
cb391342d7
* feat(mobile): map page - add map view * map: add map-markers * feat(map): add relative date filter * fix: do not let users scroll past map bounds * fix: fetch relative date from store to state on init * feat(mobile):re-fetch markers only on filter change * feat(mobile) - asset bottom sheet in map page * feat(mobile): display markers based on bottom sheet scroll * fix: exif-bottom-sheet - rebase conflict * feat(mobile): map-view - strongly typed map page events * feat(map): zoom to asset * chore: dart analyzer fixes * map-page move attribution to top-right * feat(mobile): map view - asset selection handling * feat(mobile): map-view display map in places row * fix: make asset marker icon responsive * optimise map page rebuilds * refactor(mobile): map page * feat(mobile): map-view: Go to location * map-view(mobile): minor refactor * fix(mobile): Handle invalid coords gracefully * small styling --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/shared/models/asset.dart';
|
|
import 'package:immich_mobile/shared/providers/api.provider.dart';
|
|
import 'package:immich_mobile/shared/providers/db.provider.dart';
|
|
import 'package:immich_mobile/shared/services/api.service.dart';
|
|
import 'package:isar/isar.dart';
|
|
import 'package:logging/logging.dart';
|
|
import 'package:openapi/api.dart';
|
|
|
|
final mapServiceProvider = Provider(
|
|
(ref) => MapSerivce(
|
|
ref.read(apiServiceProvider),
|
|
ref.read(dbProvider),
|
|
),
|
|
);
|
|
|
|
class MapSerivce {
|
|
final ApiService _apiService;
|
|
final Isar _db;
|
|
final log = Logger("MapService");
|
|
|
|
MapSerivce(this._apiService, this._db);
|
|
|
|
Future<List<MapMarkerResponseDto>> getMapMarkers({
|
|
bool? isFavorite,
|
|
DateTime? fileCreatedAfter,
|
|
DateTime? fileCreatedBefore,
|
|
}) async {
|
|
try {
|
|
final markers = await _apiService.assetApi.getMapMarkers(
|
|
isFavorite: isFavorite,
|
|
fileCreatedAfter: fileCreatedAfter,
|
|
fileCreatedBefore: fileCreatedBefore,
|
|
);
|
|
|
|
return markers ?? [];
|
|
} catch (error, stack) {
|
|
log.severe("Cannot get map markers ${error.toString()}", error, stack);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
Future<Asset?> getAssetForMarkerId(String remoteId) async {
|
|
try {
|
|
final assets = await _db.assets.getAllByRemoteId([remoteId]);
|
|
if (assets.isNotEmpty) return assets[0];
|
|
|
|
final dto = await _apiService.assetApi.getAssetById(remoteId);
|
|
if (dto == null) {
|
|
return null;
|
|
}
|
|
return Asset.remote(dto);
|
|
} catch (error, stack) {
|
|
log.severe(
|
|
"Cannot get asset for marker ${error.toString()}",
|
|
error,
|
|
stack,
|
|
);
|
|
return null;
|
|
}
|
|
}
|
|
}
|