mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
improve ui
This commit is contained in:
@@ -153,6 +153,8 @@ class HistoryManager with ChangeNotifier {
|
||||
|
||||
Map<String, bool>? _cachedHistory;
|
||||
|
||||
static const _kMaxHistoryLength = 200;
|
||||
|
||||
Future<void> init() async {
|
||||
_db = sqlite3.open("${App.dataPath}/history.db");
|
||||
|
||||
@@ -176,6 +178,12 @@ class HistoryManager with ChangeNotifier {
|
||||
///
|
||||
/// This function would be called when user start reading.
|
||||
Future<void> addHistory(History newItem) async {
|
||||
while(count() >= _kMaxHistoryLength) {
|
||||
_db.execute("""
|
||||
delete from history
|
||||
where time == (select min(time) from history);
|
||||
""");
|
||||
}
|
||||
_db.execute("""
|
||||
insert or replace into history (id, title, subtitle, cover, time, type, ep, page, readEpisode, max_page)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
||||
@@ -207,6 +215,7 @@ class HistoryManager with ChangeNotifier {
|
||||
where id == ? and type == ?;
|
||||
""", [id, type.value]);
|
||||
updateCache();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<History?> find(String id, ComicType type) async {
|
||||
|
Reference in New Issue
Block a user