2023-02-05 05:25:11 +02:00
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
2023-05-17 19:36:02 +02:00
|
|
|
import 'package:immich_mobile/modules/home/ui/asset_grid/asset_grid_data_structure.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-11-13 17:54:41 +02:00
|
|
|
import 'package:immich_mobile/utils/renderlist_generator.dart';
|
2023-05-17 19:36:02 +02:00
|
|
|
import 'package:isar/isar.dart';
|
|
|
|
|
2023-11-13 17:54:41 +02:00
|
|
|
final favoriteAssetsProvider = StreamProvider<RenderList>((ref) {
|
2023-05-25 05:52:43 +02:00
|
|
|
final user = ref.watch(currentUserProvider);
|
2023-11-13 17:54:41 +02:00
|
|
|
if (user == null) return const Stream.empty();
|
2023-05-17 19:36:02 +02:00
|
|
|
final query = ref
|
|
|
|
.watch(dbProvider)
|
|
|
|
.assets
|
2023-09-28 05:43:55 +02:00
|
|
|
.where()
|
|
|
|
.ownerIdEqualToAnyChecksum(user.isarId)
|
2023-05-17 19:36:02 +02:00
|
|
|
.filter()
|
|
|
|
.isFavoriteEqualTo(true)
|
2023-10-06 09:01:14 +02:00
|
|
|
.isTrashedEqualTo(false)
|
2023-12-07 17:38:22 +02:00
|
|
|
.sortByFileCreatedAtDesc();
|
2023-11-13 17:54:41 +02:00
|
|
|
return renderListGenerator(query, ref);
|
2023-02-05 05:25:11 +02:00
|
|
|
});
|