fix(mine): 支持未登录展示互动计数

This commit is contained in:
Zhou Weidong committed 2026-10-27 10:26:11 +08:00
1 parent 06a2f6d7c0
commit 8d511933df
4 files changed
+334 -19

No files matched your search

+20 -3
View File
@@ -18,6 +18,7 @@ class MineLogic extends ChangeNotifier {
bool recentLoading = false;
String? recentError;
bool _disposed = false;
int _requestSeq = 0;
void notify() {
if (!_disposed) notifyListeners();
@@ -25,21 +26,37 @@ class MineLogic extends ChangeNotifier {
/// 最近观看:取分页首屏,剧名封面仍由目录卡片按 id 映射。
Future<void> refreshRecent() async {
final request = ++_requestSeq;
recentLoading = true;
recentError = null;
notify();
try {
final page = await history.recent(pageIndex: 1, pageSize: 10);
if (_disposed || request != _requestSeq) return;
recent = page.list;
watchRecordTotal = page.total;
} catch (_) {
recentError = 'progressError';
if (!_disposed && request == _requestSeq) {
recentError = 'progressError';
}
} finally {
recentLoading = false;
notify();
if (!_disposed && request == _requestSeq) {
recentLoading = false;
notify();
}
}
}
/// 切换账号/设备身份时先清空,避免旧身份数据回写或短暂混显。
void resetRecent() {
_requestSeq += 1;
recent = const [];
watchRecordTotal = null;
recentLoading = false;
recentError = null;
notify();
}
/// 页面重新可见时刷新最近观看,避免停留在旧进度。
void syncPage({required bool active, required bool wasActive}) {
if (active && !wasActive) refreshRecent();