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