Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mobile): show all places don't show all places #9193

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:immich_mobile/models/search/search_curated_content.model.dart';

import 'package:immich_mobile/modules/search/services/search.service.dart';

final getPlacesProvider =
final getPreviewPlacesProvider =
FutureProvider.autoDispose<List<SearchCuratedContent>>((ref) async {
final SearchService searchService = ref.watch(searchServiceProvider);

Expand All @@ -27,3 +27,25 @@ final getPlacesProvider =

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;
});
9 changes: 9 additions & 0 deletions mobile/lib/modules/search/services/search.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,13 @@ class SearchService {
}
return null;
}

Future<List<AssetResponseDto>?> getAllPlaces() async {
try {
return await _apiService.searchApi.getAssetsByCity();
} catch (error, stackTrace) {
_log.severe("Failed to getAllPlaces", error, stackTrace);
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import 'package:immich_mobile/modules/search/providers/search_page_state.provide
import 'package:immich_mobile/modules/search/ui/explore_grid.dart';

@RoutePage()
class CuratedLocationPage extends HookConsumerWidget {
const CuratedLocationPage({super.key});
class AllPlacesPage extends HookConsumerWidget {
const AllPlacesPage({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
AsyncValue<List<SearchCuratedContent>> places =
ref.watch(getPlacesProvider);
ref.watch(getAllPlacesProvider);

return Scaffold(
appBar: AppBar(
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/modules/search/views/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SearchPage extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final places = ref.watch(getPlacesProvider);
final places = ref.watch(getPreviewPlacesProvider);
final curatedPeople = ref.watch(getAllPeopleProvider);
final isMapEnabled =
ref.watch(serverInfoProvider.select((v) => v.serverFeatures.map));
Expand Down Expand Up @@ -174,7 +174,7 @@ class SearchPage extends HookConsumerWidget {
SearchRowTitle(
title: "search_page_places".tr(),
onViewAllPressed: () =>
context.pushRoute(const CuratedLocationRoute()),
context.pushRoute(const AllPlacesRoute()),
top: 0,
),
const SizedBox(height: 10.0),
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import 'package:immich_mobile/modules/trash/views/trash_page.dart';
import 'package:immich_mobile/modules/search/views/all_motion_videos_page.dart';
import 'package:immich_mobile/modules/search/views/all_people_page.dart';
import 'package:immich_mobile/modules/search/views/all_videos_page.dart';
import 'package:immich_mobile/modules/search/views/curated_location_page.dart';
import 'package:immich_mobile/modules/search/views/all_places_page.dart';
import 'package:immich_mobile/modules/search/views/person_result_page.dart';
import 'package:immich_mobile/modules/search/views/recently_added_page.dart';
import 'package:immich_mobile/modules/search/views/search_page.dart';
Expand Down Expand Up @@ -127,7 +127,7 @@ class AppRouter extends _$AppRouter {
guards: [_authGuard, _duplicateGuard, _backupPermissionGuard],
),
AutoRoute(
page: CuratedLocationRoute.page,
page: AllPlacesRoute.page,
guards: [_authGuard, _duplicateGuard],
),
AutoRoute(
Expand Down
12 changes: 6 additions & 6 deletions mobile/lib/routing/router.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mobile/lib/routing/tab_navigation_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class TabNavigationObserver extends AutoRouterObserver {
// Perform tasks on re-visit to SearchRoute
if (route.name == 'SearchRoute') {
// Refresh Location State
ref.invalidate(getPlacesProvider);
ref.invalidate(getPreviewPlacesProvider);
ref.invalidate(getAllPeopleProvider);
}

Expand Down
Loading