fix: 优化播放页面章节列表

This commit is contained in:
rang 2025-12-26 16:12:30 +08:00
parent 0a26871bb1
commit 612e8b3f50
7 changed files with 96 additions and 153 deletions

View file

@ -152,9 +152,9 @@ class PlayerState extends _$PlayerState {
}
@riverpod
Duration? currentTime(Ref ref, String libraryItemId) {
final me = ref.watch(meProvider);
final userProgress = me.valueOrNull?.mediaProgress
Future<Duration?> currentTime(Ref ref, String libraryItemId) async {
final me = await ref.watch(meProvider.future);
final userProgress = me.mediaProgress
?.firstWhereOrNull((element) => element.libraryItemId == libraryItemId);
return userProgress?.currentTime;
}
@ -192,7 +192,8 @@ class CurrentBook extends _$CurrentBook {
}
final book = await ref.read(libraryItemProvider(libraryItemId).future);
state = book.media.asBookExpanded;
final currentTime = ref.read(currentTimeProvider(libraryItemId));
final currentTime =
await ref.read(currentTimeProvider(libraryItemId).future);
await ref
.read(absPlayerProvider.notifier)
.load(state!, initialPosition: currentTime, play: play);