2023-03-25 05:44:53 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2024-05-01 04:36:40 +02:00
|
|
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
2024-05-02 22:59:14 +02:00
|
|
|
import 'package:immich_mobile/providers/db.provider.dart';
|
|
|
|
import 'package:immich_mobile/providers/user.provider.dart';
|
2023-12-28 07:33:37 +02:00
|
|
|
import 'package:isar/isar.dart';
|
2023-03-25 05:44:53 +02:00
|
|
|
|
2024-05-02 22:59:14 +02:00
|
|
|
final recentlyAddedAssetProvider = FutureProvider<List<Asset>>((ref) async {
|
2024-03-22 15:41:55 +02:00
|
|
|
final user = ref.read(currentUserProvider);
|
|
|
|
if (user == null) return [];
|
|
|
|
|
2024-01-27 18:14:32 +02:00
|
|
|
return ref
|
|
|
|
.watch(dbProvider)
|
2023-03-25 05:44:53 +02:00
|
|
|
.assets
|
2023-12-28 07:33:37 +02:00
|
|
|
.where()
|
2024-03-22 15:41:55 +02:00
|
|
|
.ownerIdEqualToAnyChecksum(user.isarId)
|
2023-12-28 07:33:37 +02:00
|
|
|
.sortByFileCreatedAtDesc()
|
|
|
|
.findAll();
|
2023-03-25 05:44:53 +02:00
|
|
|
});
|