Allow user to keep favorite and history when delete local comic. Close #420

This commit is contained in:
角砂糖
2025-06-22 19:49:09 +08:00
parent 8eda8adcc8
commit 01acc4f9de
3 changed files with 31 additions and 11 deletions

View File

@@ -236,6 +236,7 @@
"No Category Pages": "没有分类页面", "No Category Pages": "没有分类页面",
"Chapter @ep": "第 @ep 章", "Chapter @ep": "第 @ep 章",
"Page @page": "第 @page 页", "Page @page": "第 @page 页",
"Remove local favorite and history": "删除本地收藏和历史记录",
"Also remove files on disk": "同时删除磁盘上的文件", "Also remove files on disk": "同时删除磁盘上的文件",
"Copy to app local path": "将漫画复制到本地存储目录中", "Copy to app local path": "将漫画复制到本地存储目录中",
"Delete all unavailable local favorite items": "删除所有无效的本地收藏", "Delete all unavailable local favorite items": "删除所有无效的本地收藏",
@@ -633,6 +634,7 @@
"No Category Pages": "沒有分類頁面", "No Category Pages": "沒有分類頁面",
"Chapter @ep": "第 @ep 章", "Chapter @ep": "第 @ep 章",
"Page @page": "第 @page 頁", "Page @page": "第 @page 頁",
"Remove local favorite and history": "刪除本機收藏和歷史記錄",
"Also remove files on disk": "同時刪除磁碟上的文件", "Also remove files on disk": "同時刪除磁碟上的文件",
"Copy to app local path": "將漫畫複製到本機儲存目錄中", "Copy to app local path": "將漫畫複製到本機儲存目錄中",
"Delete all unavailable local favorite items": "刪除所有無效的本機收藏", "Delete all unavailable local favorite items": "刪除所有無效的本機收藏",

View File

@@ -611,7 +611,7 @@ class LocalManager with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void batchDeleteComics(List<LocalComic> comics, [bool removeFileOnDisk = true]) { void batchDeleteComics(List<LocalComic> comics, [bool removeFileOnDisk = true, bool removeFavoriteAndHistory = true]) {
if (comics.isEmpty) { if (comics.isEmpty) {
return; return;
} }
@@ -640,8 +640,11 @@ class LocalManager with ChangeNotifier {
_db.execute('COMMIT;'); _db.execute('COMMIT;');
var comicIDs = comics.map((e) => ComicID(e.comicType, e.id)).toList(); var comicIDs = comics.map((e) => ComicID(e.comicType, e.id)).toList();
LocalFavoritesManager().batchDeleteComicsInAllFolders(comicIDs);
HistoryManager().batchDeleteHistories(comicIDs); if (removeFavoriteAndHistory) {
LocalFavoritesManager().batchDeleteComicsInAllFolders(comicIDs);
HistoryManager().batchDeleteHistories(comicIDs);
}
notifyListeners(); notifyListeners();

View File

@@ -361,17 +361,31 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
context: App.rootContext, context: App.rootContext,
builder: (context) { builder: (context) {
bool removeComicFile = true; bool removeComicFile = true;
bool removeFavoriteAndHistory = true;
return StatefulBuilder(builder: (context, state) { return StatefulBuilder(builder: (context, state) {
return ContentDialog( return ContentDialog(
title: "Delete".tl, title: "Delete".tl,
content: CheckboxListTile( content: Column(
title: Text("Also remove files on disk".tl), children: [
value: removeComicFile, CheckboxListTile(
onChanged: (v) { title: Text("Remove local favorite and history".tl),
state(() { value: removeFavoriteAndHistory,
removeComicFile = !removeComicFile; onChanged: (v) {
}); state(() {
}, removeFavoriteAndHistory = !removeFavoriteAndHistory;
});
},
),
CheckboxListTile(
title: Text("Also remove files on disk".tl),
value: removeComicFile,
onChanged: (v) {
state(() {
removeComicFile = !removeComicFile;
});
},
)
],
), ),
actions: [ actions: [
if (comics.length == 1 && comics.first.hasChapters) if (comics.length == 1 && comics.first.hasChapters)
@@ -388,6 +402,7 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
LocalManager().batchDeleteComics( LocalManager().batchDeleteComics(
comics, comics,
removeComicFile, removeComicFile,
removeFavoriteAndHistory,
); );
isDeleted = true; isDeleted = true;
}, },