content: import 'package:isar/isar.dart';
  import 'package:mangayomi/main.dart';
  import 'package:mangayomi/models/chapter.dart';
  import 'package:mangayomi/models/update.dart';
  import 'package:mangayomi/models/history.dart';
  import 'package:mangayomi/models/manga.dart';
  import 'package:riverpod_annotation/riverpod_annotation.dart';
  import 'package:flutter_riverpod/flutter_riverpod.dart';
  part 'isar_providers.g.dart';
  
  @riverpod
  Stream<List<History>> getAllHistoryStream(
    Ref ref, {
    required ItemType itemType,
    String search = "",
  }) async* {
    yield* isar.historys
        .filter()
        .idIsNotNull()
        .and()
        .chapter((q) => q.manga((q) => q.itemTypeEqualTo(itemType)))
        .and()
        .chapter(
          (q) => q.manga((q) => q.nameContains(search, caseSensitive: false)),
        )
        .watch(fireImmediately: true);
  }
  
  @riverpod
  Stream<List<Update>> getAllUpdateStream(
    Ref ref, {
    required ItemType itemType,
    String search = "",
  }) async* {
    yield* isar.updates
        .filter()
        .idIsNotNull()
        .and()
        .chapter((q) => q.manga((q) => q.itemTypeEqualTo(itemType)))
        .and()
        .chapter(
          (q) => q.manga((q) => q.nameContains(search, caseSensitive: false)),
        )
        .watch(fireImmediately: true);
  }
  