mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Avoid updating history too frequently.
This commit is contained in:
@@ -245,8 +245,17 @@ class HistoryManager with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
bool _haveAsyncTask = false;
|
||||
|
||||
/// Create a isolate to add history to prevent blocking the UI thread.
|
||||
Future<void> addHistoryAsync(History newItem) async {
|
||||
_addHistoryAsync(_db.handle.address, newItem);
|
||||
while (_haveAsyncTask) {
|
||||
await Future.delayed(Duration(milliseconds: 20));
|
||||
}
|
||||
|
||||
_haveAsyncTask = true;
|
||||
await _addHistoryAsync(_db.handle.address, newItem);
|
||||
_haveAsyncTask = false;
|
||||
}
|
||||
|
||||
/// add history. if exists, update time.
|
||||
|
Reference in New Issue
Block a user