From fd3a1a4da8516e21ab595cd4bb434d6959639a6a Mon Sep 17 00:00:00 2001 From: Emanuel Bennici Date: Thu, 28 Dec 2023 06:33:37 +0100 Subject: [PATCH] fix(mobile): Fix "Live Images" and "Recently added" page (#6030) * fix(mobile): Load assets on "Live-Images" page Instead of requesting the server for the relevant entries, we can use the local DB. This change fixes loading errors when going to the "Live-Images" page. It is similar to the work done with #5971. * fix(mobile): Fix Recently added page --- .../providers/all_motion_photos.provider.dart | 27 ++++--------------- .../providers/recently_added.provider.dart | 16 +++-------- 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/mobile/lib/modules/search/providers/all_motion_photos.provider.dart b/mobile/lib/modules/search/providers/all_motion_photos.provider.dart index 7e20fa793f..3782eb6995 100644 --- a/mobile/lib/modules/search/providers/all_motion_photos.provider.dart +++ b/mobile/lib/modules/search/providers/all_motion_photos.provider.dart @@ -1,29 +1,12 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/shared/models/asset.dart'; -import 'package:immich_mobile/shared/providers/api.provider.dart'; import 'package:immich_mobile/shared/providers/db.provider.dart'; +import 'package:isar/isar.dart'; final allMotionPhotosProvider = FutureProvider>( (ref) async { - final search = await ref.watch(apiServiceProvider).searchApi.search( - motion: true, - ); - - if (search == null) { - return []; - } - return ref.watch(dbProvider) - .assets - .getAllByRemoteId( - search.assets.items.map((e) => e.id), - ); - - - /// This works offline, but we use the above - /* - return ref.watch(dbProvider).assets - .filter() - .livePhotoVideoIdIsNotNull() - .findAll(); - */ + .assets + .filter() + .livePhotoVideoIdIsNotNull() + .findAll(); }); diff --git a/mobile/lib/modules/search/providers/recently_added.provider.dart b/mobile/lib/modules/search/providers/recently_added.provider.dart index a4c7a829b4..5cac2fc4cf 100644 --- a/mobile/lib/modules/search/providers/recently_added.provider.dart +++ b/mobile/lib/modules/search/providers/recently_added.provider.dart @@ -1,20 +1,12 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:immich_mobile/shared/models/asset.dart'; -import 'package:immich_mobile/shared/providers/api.provider.dart'; import 'package:immich_mobile/shared/providers/db.provider.dart'; +import 'package:isar/isar.dart'; final recentlyAddedProvider = FutureProvider>( (ref) async { - final search = await ref.watch(apiServiceProvider).searchApi.search( - recent: true, - ); - - if (search == null) { - return []; - } - return ref.watch(dbProvider) .assets - .getAllByRemoteId( - search.assets.items.map((e) => e.id), - ); + .where() + .sortByFileCreatedAtDesc() + .findAll(); });