fix(favorite): 统一收藏状态与互动图标
This commit is contained in:
1 parent
4b97f89c0b
commit
d3dbc9f8dc
13 files changed
+347
-213
No files matched your search
@@ -119,7 +119,6 @@ class PlayerLogic extends ChangeNotifier {
|
||||
final Map<String, Future<void>> _episodeStatsInFlight = {};
|
||||
final Map<String, int> _episodeStatsRevision = {};
|
||||
final Map<String, int> _dramaStatsRevision = {};
|
||||
final Map<String, int> _dramaFavoriteCounts = {};
|
||||
|
||||
/// 解锁中的集 id 与失败文案;空表示没有进行中的解锁。
|
||||
String? unlockingEpisodeId;
|
||||
@@ -185,8 +184,6 @@ class PlayerLogic extends ChangeNotifier {
|
||||
|
||||
EpisodeStats? episodeStats(String episodeId) => _episodeStats[episodeId];
|
||||
|
||||
int? dramaFavoriteCount(String dramaId) => _dramaFavoriteCounts[dramaId];
|
||||
|
||||
void notify() {
|
||||
if (!_disposed) notifyListeners();
|
||||
}
|
||||
@@ -621,9 +618,6 @@ class PlayerLogic extends ChangeNotifier {
|
||||
);
|
||||
_episodeStats[episodeId] = stats;
|
||||
_episodeStatsFetchedAt[episodeId] = _clock();
|
||||
if (stats.dramaId.isNotEmpty) {
|
||||
_dramaFavoriteCounts[stats.dramaId] = stats.favoriteCount;
|
||||
}
|
||||
final episodeIndex = sessionEpisodes.indexWhere(
|
||||
(episode) => episode.id == episodeId,
|
||||
);
|
||||
@@ -703,29 +697,13 @@ class PlayerLogic extends ChangeNotifier {
|
||||
notify();
|
||||
}
|
||||
|
||||
/// 收藏成功时同时修正剧级计数和所有已缓存的同剧互动状态。
|
||||
void applyDramaFavoriteState(
|
||||
String dramaId, {
|
||||
required bool favorited,
|
||||
int? favoriteCount,
|
||||
}) {
|
||||
/// 收藏成功后让旧 stats 请求失效,计数本身只写 FavoriteController。
|
||||
void markDramaFavoriteChanged(String dramaId) {
|
||||
_dramaStatsRevision.update(
|
||||
dramaId,
|
||||
(value) => value + 1,
|
||||
ifAbsent: () => 1,
|
||||
);
|
||||
if (favoriteCount != null) {
|
||||
_dramaFavoriteCounts[dramaId] = favoriteCount;
|
||||
}
|
||||
for (final entry in _episodeStats.entries.toList()) {
|
||||
final stats = entry.value;
|
||||
if (stats.dramaId != dramaId) continue;
|
||||
_episodeStats[entry.key] = stats.copyWith(
|
||||
favorited: favorited,
|
||||
favoriteCount: favoriteCount,
|
||||
);
|
||||
}
|
||||
notify();
|
||||
}
|
||||
|
||||
String _fileUrl(String path) =>
|
||||
|
||||
Reference in new issue
Block a user