mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
fix history length
This commit is contained in:
@@ -201,8 +201,6 @@ class HistoryManager with ChangeNotifier {
|
|||||||
|
|
||||||
Map<String, bool>? _cachedHistory;
|
Map<String, bool>? _cachedHistory;
|
||||||
|
|
||||||
static const _kMaxHistoryLength = 200;
|
|
||||||
|
|
||||||
Future<void> init() async {
|
Future<void> init() async {
|
||||||
_db = sqlite3.open("${App.dataPath}/history.db");
|
_db = sqlite3.open("${App.dataPath}/history.db");
|
||||||
|
|
||||||
@@ -228,12 +226,6 @@ class HistoryManager with ChangeNotifier {
|
|||||||
///
|
///
|
||||||
/// This function would be called when user start reading.
|
/// This function would be called when user start reading.
|
||||||
Future<void> addHistory(History newItem) async {
|
Future<void> addHistory(History newItem) async {
|
||||||
while(count() >= _kMaxHistoryLength) {
|
|
||||||
_db.execute("""
|
|
||||||
delete from history
|
|
||||||
where time == (select min(time) from history);
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
_db.execute("""
|
_db.execute("""
|
||||||
insert or replace into history (id, title, subtitle, cover, time, type, ep, page, readEpisode, max_page)
|
insert or replace into history (id, title, subtitle, cover, time, type, ep, page, readEpisode, max_page)
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||||
|
Reference in New Issue
Block a user