From 84d920f98f3e1c3e62bf0ca6abc4f915e485eb74 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 19 Jan 2026 22:31:38 -0800 Subject: [PATCH] fix(kline): stop loading when no unique new history data When deduplicated new klines are empty, mark hasMoreHistory as false to prevent infinite loading attempts. Co-Authored-By: Claude Opus 4.5 --- .../lib/presentation/providers/trading_providers.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/frontend/mining-app/lib/presentation/providers/trading_providers.dart b/frontend/mining-app/lib/presentation/providers/trading_providers.dart index a06cd7aa..969e7002 100644 --- a/frontend/mining-app/lib/presentation/providers/trading_providers.dart +++ b/frontend/mining-app/lib/presentation/providers/trading_providers.dart @@ -154,10 +154,17 @@ class KlinesNotifier extends StateNotifier { (k) => !existingTimes.contains(k.time.millisecondsSinceEpoch) ).toList(); + // 如果去重后没有新数据,说明已经没有更多历史了 + if (uniqueNewKlines.isEmpty) { + state = state.copyWith(isLoadingMore: false, hasMoreHistory: false); + return; + } + final combinedKlines = [...uniqueNewKlines, ...state.klines]; // 按时间排序 combinedKlines.sort((a, b) => a.time.compareTo(b.time)); + // 判断是否还有更多历史:返回数据少于100条说明到底了 state = state.copyWith( klines: combinedKlines, isLoadingMore: false,