Make sure the follow updates is initialized correctly.

This commit is contained in:
2025-03-13 16:09:17 +08:00
parent 8e964468ea
commit 309df2143b
2 changed files with 42 additions and 27 deletions

View File

@@ -224,7 +224,8 @@ class LocalFavoritesManager with ChangeNotifier {
source_folder text
);
""");
for (var folder in _getFolderNamesWithDB()) {
var folderNames = _getFolderNamesWithDB();
for (var folder in folderNames) {
var columns = _db.select("""
pragma table_info("$folder");
""");
@@ -246,6 +247,15 @@ class LocalFavoritesManager with ChangeNotifier {
break;
}
}
await appdata.ensureInit();
// Make sure the follow updates folder is ready
var followUpdateFolder = appdata.settings['followUpdatesFolder'];
if (followUpdateFolder is String &&
folderNames.contains(followUpdateFolder)) {
prepareTableForFollowUpdates(followUpdateFolder, false);
} else {
appdata.settings['followUpdatesFolder'] = null;
}
}
List<String> find(String id, ComicType type) {
@@ -849,7 +859,7 @@ class LocalFavoritesManager with ChangeNotifier {
}
}
void prepareTableForFollowUpdates(String table) {
void prepareTableForFollowUpdates(String table, [bool clearData = true]) {
// check if the table has the column "last_update_time" "has_new_update" "last_check_time"
var columns = _db.select("""
pragma table_info("$table");
@@ -866,10 +876,12 @@ class LocalFavoritesManager with ChangeNotifier {
add column has_new_update int;
""");
}
_db.execute("""
if (clearData) {
_db.execute("""
update "$table"
set has_new_update = 0;
""");
}
if (!columns.any((element) => element["name"] == "last_check_time")) {
_db.execute("""
alter table "$table"