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