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
This commit is contained in:
Emanuel Bennici 2023-12-28 06:33:37 +01:00 committed by GitHub
parent 27bc777581
commit fd3a1a4da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 34 deletions

View File

@ -1,29 +1,12 @@
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/shared/models/asset.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:immich_mobile/shared/providers/db.provider.dart';
import 'package:isar/isar.dart';
final allMotionPhotosProvider = FutureProvider<List<Asset>>( (ref) async { final allMotionPhotosProvider = FutureProvider<List<Asset>>( (ref) async {
final search = await ref.watch(apiServiceProvider).searchApi.search(
motion: true,
);
if (search == null) {
return [];
}
return ref.watch(dbProvider) return ref.watch(dbProvider)
.assets .assets
.getAllByRemoteId( .filter()
search.assets.items.map((e) => e.id), .livePhotoVideoIdIsNotNull()
); .findAll();
/// This works offline, but we use the above
/*
return ref.watch(dbProvider).assets
.filter()
.livePhotoVideoIdIsNotNull()
.findAll();
*/
}); });

View File

@ -1,20 +1,12 @@
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/shared/models/asset.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:immich_mobile/shared/providers/db.provider.dart';
import 'package:isar/isar.dart';
final recentlyAddedProvider = FutureProvider<List<Asset>>( (ref) async { final recentlyAddedProvider = FutureProvider<List<Asset>>( (ref) async {
final search = await ref.watch(apiServiceProvider).searchApi.search(
recent: true,
);
if (search == null) {
return [];
}
return ref.watch(dbProvider) return ref.watch(dbProvider)
.assets .assets
.getAllByRemoteId( .where()
search.assets.items.map((e) => e.id), .sortByFileCreatedAtDesc()
); .findAll();
}); });