1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-23 02:06:15 +02:00
immich/mobile/lib/modules/search/providers/search_page_state.provider.dart
Alex c0495ca23f
fix(mobile): show all places don't show all places (#9193)
fix(mobile): show all places doesn't show all places
2024-04-30 22:14:33 -05:00

52 lines
1.3 KiB
Dart

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/models/search/search_curated_content.model.dart';
import 'package:immich_mobile/modules/search/services/search.service.dart';
final getPreviewPlacesProvider =
FutureProvider.autoDispose<List<SearchCuratedContent>>((ref) async {
final SearchService searchService = ref.watch(searchServiceProvider);
final exploreData = await searchService.getExploreData();
if (exploreData == null) {
return [];
}
final locations =
exploreData.firstWhere((data) => data.fieldName == "exifInfo.city").items;
final curatedContent = locations
.map(
(l) => SearchCuratedContent(
label: l.value,
id: l.data.id,
),
)
.toList();
return curatedContent;
});
final getAllPlacesProvider =
FutureProvider.autoDispose<List<SearchCuratedContent>>((ref) async {
final SearchService searchService = ref.watch(searchServiceProvider);
final assetPlaces = await searchService.getAllPlaces();
if (assetPlaces == null) {
return [];
}
final curatedContent = assetPlaces
.map(
(data) => SearchCuratedContent(
label: data.exifInfo!.city!,
id: data.id,
),
)
.toList();
return curatedContent;
});