fix(favorite): 统一收藏状态与互动图标
This commit is contained in:
1 parent
4b97f89c0b
commit
d3dbc9f8dc
13 files changed
+347
-213
No files matched your search
@@ -564,6 +564,7 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
context.read<FavoriteController>().applyServerState(
|
||||
stats.dramaId,
|
||||
saved: stats.favorited,
|
||||
favoriteCount: stats.favoriteCount,
|
||||
);
|
||||
}
|
||||
setState(() {
|
||||
@@ -571,21 +572,6 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
});
|
||||
}
|
||||
|
||||
/// 收藏状态确认后同步右侧剧级计数。
|
||||
void _applyFavoriteDelta(Drama drama, {required bool nowSaved}) {
|
||||
final current = logic.dramaFavoriteCount(drama.id) ?? drama.favoriteCount;
|
||||
final next = current == null
|
||||
? null
|
||||
: nowSaved
|
||||
? current + 1
|
||||
: (current > 0 ? current - 1 : 0);
|
||||
logic.applyDramaFavoriteState(
|
||||
drama.id,
|
||||
favorited: nowSaved,
|
||||
favoriteCount: next,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _openComments(
|
||||
BuildContext context,
|
||||
Drama drama,
|
||||
@@ -1026,6 +1012,7 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
InteractionController interactions,
|
||||
) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final favorites = context.watch<FavoriteController>();
|
||||
final entry = logic.queue.entryAt(index);
|
||||
final drama = entry.drama;
|
||||
final episode = _resolvedEpisode(index);
|
||||
@@ -1194,13 +1181,12 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
liked: interactions.isEpisodeLiked(episode.id),
|
||||
likeCount:
|
||||
interactions.episodeLikeCount(episode.id) ?? episode.likeCount,
|
||||
favoriteCount:
|
||||
logic.dramaFavoriteCount(drama.id) ?? drama.favoriteCount,
|
||||
favoriteCount: favorites.favoriteCountFor(drama),
|
||||
commentCount:
|
||||
logic.episodeStats(episode.id)?.commentCount ??
|
||||
_commentCounts[episode.id] ??
|
||||
episode.commentCount,
|
||||
saved: context.watch<FavoriteController>().isSaved(drama.id),
|
||||
saved: favorites.isSaved(drama.id),
|
||||
onLike: () async {
|
||||
await _toggleLike(context, interactions, episode);
|
||||
},
|
||||
@@ -1277,6 +1263,7 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
) {
|
||||
if (logic.pip || logic.pipPreparing) return const SizedBox.expand();
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final favorites = context.watch<FavoriteController>();
|
||||
final entry = logic.queue.entryAt(index);
|
||||
final drama = entry.drama;
|
||||
final episode = _resolvedEpisode(index);
|
||||
@@ -1306,9 +1293,8 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
logic.episodeStats(episode.id)?.commentCount ??
|
||||
_commentCounts[episode.id] ??
|
||||
episode.commentCount,
|
||||
favoriteCount:
|
||||
logic.dramaFavoriteCount(drama.id) ?? drama.favoriteCount,
|
||||
saved: context.watch<FavoriteController>().isSaved(drama.id),
|
||||
favoriteCount: favorites.favoriteCountFor(drama),
|
||||
saved: favorites.isSaved(drama.id),
|
||||
playing: logic.session.userWantsPlay,
|
||||
playbackSpeed: _playbackSpeed,
|
||||
totalEpisodes: logic.visibleIndices.length,
|
||||
|
||||
Reference in new issue
Block a user