Improve performance of deleting favorites, coping favorites, moving favorites and deleting downloads. Close #365

This commit is contained in:
2025-05-24 16:24:53 +08:00
parent ed70fdba93
commit dcd6466547
7 changed files with 266 additions and 42 deletions

View File

@@ -406,4 +406,23 @@ void clearUnfavoritedHistory() {
isInitialized = false;
_db.dispose();
}
void batchDeleteHistories(List<ComicID> histories) {
if (histories.isEmpty) return;
_db.execute('BEGIN TRANSACTION;');
try {
for (var history in histories) {
_db.execute("""
delete from history
where id == ? and type == ?;
""", [history.id, history.type.value]);
}
_db.execute('COMMIT;');
} catch (e) {
_db.execute('ROLLBACK;');
rethrow;
}
updateCache();
notifyListeners();
}
}