mangayomi/lib/views/library/providers/isar_providers.dart
2023-05-06 14:57:39 +01:00

23 lines
715 B
Dart

import 'package:isar/isar.dart';
import 'package:mangayomi/main.dart';
import 'package:mangayomi/models/manga.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'isar_providers.g.dart';
@riverpod
Stream<List<Manga>> getAllMangaStream(GetAllMangaStreamRef ref,
{required int? categoryId}) async* {
yield* categoryId == null
? isar.mangas
.filter()
.idIsNotNull()
.favoriteEqualTo(true)
.watch(fireImmediately: true)
: isar.mangas
.filter()
.idIsNotNull()
.favoriteEqualTo(true)
.categoriesIsNotEmpty()
.categoriesElementEqualTo(categoryId)
.watch(fireImmediately: true);
}