From c9b7ea97bf0300e21ad610c95460aa1771a59779 Mon Sep 17 00:00:00 2001 From: nyne Date: Fri, 14 Feb 2025 22:35:57 +0800 Subject: [PATCH] Fixed the issue where `addHistoryAsync` did not update the cache. --- lib/foundation/history.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/foundation/history.dart b/lib/foundation/history.dart index 5ca6236..bd21d1d 100644 --- a/lib/foundation/history.dart +++ b/lib/foundation/history.dart @@ -256,6 +256,16 @@ class HistoryManager with ChangeNotifier { _haveAsyncTask = true; await _addHistoryAsync(_db.handle.address, newItem); _haveAsyncTask = false; + if (_cachedHistoryIds == null) { + updateCache(); + } else { + _cachedHistoryIds![newItem.id] = true; + } + cachedHistories[newItem.id] = newItem; + if (cachedHistories.length > 10) { + cachedHistories.remove(cachedHistories.keys.first); + } + notifyListeners(); } /// add history. if exists, update time.