2022-02-27 18:45:12 +00:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2024-05-01 02:36:40 +00:00
|
|
|
import 'package:immich_mobile/models/search/search_curated_content.model.dart';
|
2022-02-27 18:45:12 +00:00
|
|
|
|
2024-05-02 20:59:14 +00:00
|
|
|
import 'package:immich_mobile/services/search.service.dart';
|
2022-02-27 18:43:29 +00:00
|
|
|
|
2024-05-01 03:14:33 +00:00
|
|
|
final getPreviewPlacesProvider =
|
2024-05-01 02:36:40 +00:00
|
|
|
FutureProvider.autoDispose<List<SearchCuratedContent>>((ref) async {
|
2024-04-26 05:49:31 +00:00
|
|
|
final SearchService searchService = ref.watch(searchServiceProvider);
|
2022-02-27 18:43:29 +00:00
|
|
|
|
2024-04-26 05:49:31 +00:00
|
|
|
final exploreData = await searchService.getExploreData();
|
2022-02-27 18:43:29 +00:00
|
|
|
|
2024-04-26 05:49:31 +00:00
|
|
|
if (exploreData == null) {
|
|
|
|
return [];
|
2022-02-27 18:43:29 +00:00
|
|
|
}
|
2022-02-27 18:45:12 +00:00
|
|
|
|
2024-04-26 05:49:31 +00:00
|
|
|
final locations =
|
|
|
|
exploreData.firstWhere((data) => data.fieldName == "exifInfo.city").items;
|
2022-03-16 15:19:31 +00:00
|
|
|
|
2024-04-26 05:49:31 +00:00
|
|
|
final curatedContent = locations
|
|
|
|
.map(
|
2024-05-01 02:36:40 +00:00
|
|
|
(l) => SearchCuratedContent(
|
2024-04-26 05:49:31 +00:00
|
|
|
label: l.value,
|
|
|
|
id: l.data.id,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.toList();
|
2022-03-16 15:19:31 +00:00
|
|
|
|
2024-04-26 05:49:31 +00:00
|
|
|
return curatedContent;
|
2022-03-16 15:19:31 +00:00
|
|
|
});
|
2024-05-01 03:14:33 +00:00
|
|
|
|
|
|
|
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(
|
2024-07-02 18:43:52 +00:00
|
|
|
label: data.exifInfo!.city!,
|
2024-05-01 03:14:33 +00:00
|
|
|
id: data.id,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
return curatedContent;
|
|
|
|
});
|