From 74dc9807d6964a6f1efd1cfd15c89a7aa7caa119 Mon Sep 17 00:00:00 2001 From: Dr-Blank <64108942+Dr-Blank@users.noreply.github.com> Date: Sun, 19 May 2024 09:51:06 -0400 Subject: [PATCH] feat: Invalidate currently playing chapter when player position changes --- lib/features/player/providers/currently_playing_provider.dart | 4 ++++ .../player/providers/currently_playing_provider.g.dart | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/features/player/providers/currently_playing_provider.dart b/lib/features/player/providers/currently_playing_provider.dart index 68b5c10..607b823 100644 --- a/lib/features/player/providers/currently_playing_provider.dart +++ b/lib/features/player/providers/currently_playing_provider.dart @@ -14,6 +14,10 @@ BookExpanded? currentlyPlayingBook(CurrentlyPlayingBookRef ref) { @riverpod BookChapter? currentPlayingChapter(CurrentPlayingChapterRef ref) { final player = ref.watch(audiobookPlayerProvider); + player.positionStream.listen((_) { + ref.invalidateSelf(); + }); + return player.currentChapter; } diff --git a/lib/features/player/providers/currently_playing_provider.g.dart b/lib/features/player/providers/currently_playing_provider.g.dart index 11485b7..afcbb8c 100644 --- a/lib/features/player/providers/currently_playing_provider.g.dart +++ b/lib/features/player/providers/currently_playing_provider.g.dart @@ -24,7 +24,7 @@ final currentlyPlayingBookProvider = typedef CurrentlyPlayingBookRef = AutoDisposeProviderRef; String _$currentPlayingChapterHash() => - r'3a621260211cddecfd974b31d5c4820ed24b1545'; + r'91ca01ee93e0d556c77237ceebb3f9281d2d2b3f'; /// provided the current chapter of the book being played ///