High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix: show only owned assets in places and map (#22585)
shenlonga2b25b7a74a9
diff --git a/mobile/lib/domain/services/asset.service.dart b/mobile/lib/domain/services/asset.service.dartindex 84f675f68b..7f8ade313c 100644--- a/mobile/lib/domain/services/asset.service.dart+++ b/mobile/lib/domain/services/asset.service.dart@@ -84,8 +84,8 @@ class AssetService {return 1.0;}- Future<List<(String, String)>> getPlaces() {- return _remoteAssetRepository.getPlaces();+ Future<List<(String, String)>> getPlaces(String userId) {+ return _remoteAssetRepository.getPlaces(userId);}Future<(int local, int remote)> getAssetCounts() async {diff --git a/mobile/lib/domain/services/timeline.service.dart b/mobile/lib/domain/services/timeline.service.dartindex ab623720b7..bf354847c3 100644--- a/mobile/lib/domain/services/timeline.service.dart+++ b/mobile/lib/domain/services/timeline.service.dart@@ -59,7 +59,8 @@ class TimelineFactory {TimelineService fromAssets(List<BaseAsset> assets) => TimelineService(_timelineRepository.fromAssets(assets));- TimelineService map(LatLngBounds bounds) => TimelineService(_timelineRepository.map(bounds, groupBy));+ TimelineService map(String userId, LatLngBounds bounds) =>+ TimelineService(_timelineRepository.map(userId, bounds, groupBy));}class TimelineService {diff --git a/mobile/lib/infrastructure/repositories/remote_asset.repository.dart b/mobile/lib/infrastructure/repositories/remote_asset.repository.dartindex 092bb728d9..be55c21afc 100644--- a/mobile/lib/infrastructure/repositories/remote_asset.repository.dart+++ b/mobile/lib/infrastructure/repositories/remote_asset.repository.dart@@ -81,9 +81,11 @@ class RemoteAssetRepository extends DriftDatabaseRepository {.getSingleOrNull();}- Future<List<(String, String)>> getPlaces() {+ Future<List<(String, String)>> getPlaces(String userId) {final asset = Subquery(- _db.remoteAssetEntity.select()..orderBy([(row) => OrderingTerm.desc(row.createdAt)]),+ _db.remoteAssetEntity.select()+ ..where((row) => row.ownerId.equals(userId))+ ..orderBy([(row) => OrderingTerm.desc(row.createdAt)]),"asset",);diff --git a/mobile/lib/infrastructure/repositories/timeline.repository.dart b/mobile/lib/infrastructure/repositories/timeline.repository.dartindex 14ffafa646..05928d938f 100644--- a/mobile/lib/infrastructure/repositories/timeline.repository.dart+++ b/mobile/lib/infrastructure/repositories/timeline.repository.dart@@ -431,12 +431,16 @@ class DriftTimelineRepository extends DriftDatabaseRepository {return query.map((row) => row.readTable(_db.remoteAssetEntity).toDto()).get();}- TimelineQuery map(LatLngBounds bounds, GroupAssetsBy groupBy) => (- bucketSource: () => _watchMapBucket(bounds, groupBy: groupBy),- assetSource: (offset, count) => _getMapBucketAssets(bounds, offset: offset, count: count),+ TimelineQuery map(String userId, LatLngBounds bounds, GroupAssetsBy groupBy) => (+ bucketSource: () => _watchMapBucket(userId, bounds, groupBy: groupBy),+ assetSource: (offset, count) => _getMapBucketAssets(userId, bounds, offset: offset, count: count),);- Stream<List<Bucket>> _watchMapBucket(LatLngBounds bounds, {GroupAssetsBy groupBy = GroupAssetsBy.day}) {+ Stream<List<Bucket>> _watchMapBucket(+ String userId,+ LatLngBounds bounds, {+ GroupAssetsBy groupBy = GroupAssetsBy.day,+ }) {if (groupBy == GroupAssetsBy.none) {// TODO: Support GroupAssetsBy.nonethrow UnsupportedError("GroupAssetsBy.none is not supported for _watchMapBucket");@@ -455,7 +459,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {),])..where(- _db.remoteExifEntity.inBounds(bounds) &+ _db.remoteAssetEntity.ownerId.equals(userId) &+ _db.remoteExifEntity.inBounds(bounds) &_db.remoteAssetEntity.visibility.equalsValue(AssetVisibility.timeline) &_db.remoteAssetEntity.deletedAt.isNull(),)@@ -469,7 +474,12 @@ class DriftTimelineRepository extends DriftDatabaseRepository {}).watch();}- Future<List<BaseAsset>> _getMapBucketAssets(LatLngBounds bounds, {required int offset, required int count}) {+ Future<List<BaseAsset>> _getMapBucketAssets(+ String userId,+ LatLngBounds bounds, {+ required int offset,+ required int count,+ }) {final query =_db.remoteAssetEntity.select().join([innerJoin(@@ -479,7 +489,8 @@ class DriftTimelineRepository extends DriftDatabaseRepository {),])..where(- _db.remoteExifEntity.inBounds(bounds) &+ _db.remoteAssetEntity.ownerId.equals(userId) &+ _db.remoteExifEntity.inBounds(bounds) &_db.remoteAssetEntity.visibility.equalsValue(AssetVisibility.timeline) &_db.remoteAssetEntity.deletedAt.isNull(),)diff --git a/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart b/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dartindex dc5fdbe78d..ac3772a02b 100644--- a/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart+++ b/mobile/lib/presentation/widgets/bottom_sheet/map_bottom_sheet.widget.dart@@ -5,6 +5,7 @@ import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheeimport 'package:immich_mobile/presentation/widgets/map/map.state.dart';import 'package:immich_mobile/presentation/widgets/timeline/timeline.widget.dart';import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';+import 'package:immich_mobile/providers/user.provider.dart';class MapBottomSheet extends StatelessWidget {const MapBottomSheet({super.key});@@ -32,8 +33,13 @@ class _ScopedMapTimeline extends StatelessWidget {return ProviderScope(overrides: [timelineServiceProvider.overrideWith((ref) {+ final user = ref.watch(currentUserProvider);+ if (user == null) {+ throw Exception('User must be logged in to access archive');+ }+final bounds = ref.watch(mapStateProvider).bounds;- final timelineService = ref.watch(timelineFactoryProvider).map(bounds);+ final timelineService = ref.watch(timelineFactoryProvider).map(user.id, bounds);ref.onDispose(timelineService.dispose);return timelineService;}),diff --git a/mobile/lib/providers/infrastructure/asset.provider.dart b/mobile/lib/providers/infrastructure/asset.provider.dartindex 102e6aa60c..4b51ce33bd 100644--- a/mobile/lib/providers/infrastructure/asset.provider.dart+++ b/mobile/lib/providers/infrastructure/asset.provider.dart@@ -3,6 +3,7 @@ import 'package:immich_mobile/domain/services/asset.service.dart';import 'package:immich_mobile/infrastructure/repositories/local_asset.repository.dart';import 'package:immich_mobile/infrastructure/repositories/remote_asset.repository.dart';import 'package:immich_mobile/providers/infrastructure/db.provider.dart';+import 'package:immich_mobile/providers/user.provider.dart';final localAssetRepository = Provider<DriftLocalAssetRepository>((ref) => DriftLocalAssetRepository(ref.watch(driftProvider)),@@ -19,9 +20,13 @@ final assetServiceProvider = Provider(),);-final placesProvider = FutureProvider<List<(String, String)>>(- (ref) => AssetService(- remoteAssetRepository: ref.watch(remoteAssetRepositoryProvider),- localAssetRepository: ref.watch(localAssetRepository),- ).getPlaces(),-);+final placesProvider = FutureProvider<List<(String, String)>>((ref) {+ final assetService = ref.watch(assetServiceProvider);+ final auth = ref.watch(currentUserProvider);++ if (auth == null) {+ return Future.value(const []);+ }++ return assetService.getPlaces(auth.id);+});