1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-24 10:37:28 +02:00
immich/mobile/lib/modules/search/providers/search_page_state.provider.dart

52 lines
1.3 KiB
Dart
Raw Normal View History

2022-02-27 20:45:12 +02:00
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/models/search/search_curated_content.model.dart';
2022-02-27 20:45:12 +02:00
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 [];
}
2022-02-27 20:45:12 +02:00
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;
});