mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Add feature to download all comics in a folder
This commit is contained in:
@@ -365,10 +365,10 @@ class LocalManager with ChangeNotifier {
|
||||
return files.map((e) => "file://${e.path}").toList();
|
||||
}
|
||||
|
||||
Future<bool> isDownloaded(String id, ComicType type, int ep) async {
|
||||
Future<bool> isDownloaded(String id, ComicType type, [int? ep]) async {
|
||||
var comic = find(id, type);
|
||||
if (comic == null) return false;
|
||||
if (comic.chapters == null) return true;
|
||||
if (comic.chapters == null || ep == null) return true;
|
||||
return comic.downloadedChapters
|
||||
.contains(comic.chapters!.keys.elementAt(ep-1));
|
||||
}
|
||||
|
@@ -76,11 +76,14 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin {
|
||||
@override
|
||||
ComicType get comicType => ComicType(source.key.hashCode);
|
||||
|
||||
String? comicTitle;
|
||||
|
||||
ImagesDownloadTask({
|
||||
required this.source,
|
||||
required this.comicId,
|
||||
this.comic,
|
||||
this.chapters,
|
||||
this.comicTitle,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -379,7 +382,7 @@ class ImagesDownloadTask extends DownloadTask with _TransferSpeedMixin {
|
||||
int get speed => currentSpeed;
|
||||
|
||||
@override
|
||||
String get title => comic?.title ?? "Loading...";
|
||||
String get title => comic?.title ?? comicTitle ?? "Loading...";
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@@ -9,7 +9,9 @@ import 'package:venera/foundation/appdata.dart';
|
||||
import 'package:venera/foundation/comic_source/comic_source.dart';
|
||||
import 'package:venera/foundation/comic_type.dart';
|
||||
import 'package:venera/foundation/favorites.dart';
|
||||
import 'package:venera/foundation/local.dart';
|
||||
import 'package:venera/foundation/res.dart';
|
||||
import 'package:venera/network/download.dart';
|
||||
import 'package:venera/utils/io.dart';
|
||||
import 'package:venera/utils/translations.dart';
|
||||
|
||||
|
@@ -105,7 +105,7 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
||||
},
|
||||
).then(
|
||||
(value) {
|
||||
if(mounted) {
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
@@ -128,13 +128,40 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
|
||||
text: "Update Comics Info".tl,
|
||||
onClick: () {
|
||||
updateComicsInfo(widget.folder).then((newComics) {
|
||||
if(mounted) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
comics = newComics;
|
||||
});
|
||||
}
|
||||
});
|
||||
}),
|
||||
MenuEntry(
|
||||
icon: Icons.update,
|
||||
text: "Download All".tl,
|
||||
onClick: () async {
|
||||
int count = 0;
|
||||
for (var c in comics) {
|
||||
if (await LocalManager().isDownloaded(c.id, c.type)) {
|
||||
continue;
|
||||
}
|
||||
var comicSource = c.type.comicSource;
|
||||
if (comicSource == null) {
|
||||
continue;
|
||||
}
|
||||
LocalManager().addTask(ImagesDownloadTask(
|
||||
source: comicSource,
|
||||
comicId: c.id,
|
||||
comic: null,
|
||||
comicTitle: c.name,
|
||||
));
|
||||
count++;
|
||||
}
|
||||
context.showMessage(
|
||||
message: "Added @count comics to download queue."
|
||||
.tlParams({
|
||||
"count": count.toString(),
|
||||
}));
|
||||
}),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -219,7 +246,8 @@ class _ReorderComicsPageState extends State<_ReorderComicsPage> {
|
||||
e.author,
|
||||
e.tags,
|
||||
"${e.time} | ${comicSource?.name ?? "Unknown"}",
|
||||
comicSource?.key ?? (e.type == ComicType.local ? "local" : "Unknown"),
|
||||
comicSource?.key ??
|
||||
(e.type == ComicType.local ? "local" : "Unknown"),
|
||||
null,
|
||||
null,
|
||||
),
|
||||
|
Reference in New Issue
Block a user