1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

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: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<List<Asset>>( (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();
});

View File

@ -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<List<Asset>>( (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();
});