mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Fix an issue where it was impossible to read a new chapter of a downloaded comic. Close #256
This commit is contained in:
@@ -422,12 +422,30 @@ class LocalManager with ChangeNotifier {
|
|||||||
return files.map((e) => "file://${e.path}").toList();
|
return files.map((e) => "file://${e.path}").toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isDownloaded(String id, ComicType type, [int? ep]) {
|
bool isDownloaded(String id, ComicType type,
|
||||||
|
[int? ep, ComicChapters? chapters]) {
|
||||||
var comic = find(id, type);
|
var comic = find(id, type);
|
||||||
if (comic == null) return false;
|
if (comic == null) return false;
|
||||||
if (comic.chapters == null || ep == null) return true;
|
if (comic.chapters == null || ep == null) return true;
|
||||||
|
if (chapters != null) {
|
||||||
|
if (comic.chapters?.length != chapters.length) {
|
||||||
|
// update
|
||||||
|
add(LocalComic(
|
||||||
|
id: comic.id,
|
||||||
|
title: comic.title,
|
||||||
|
subtitle: comic.subtitle,
|
||||||
|
tags: comic.tags,
|
||||||
|
directory: comic.directory,
|
||||||
|
chapters: chapters,
|
||||||
|
cover: comic.cover,
|
||||||
|
comicType: comic.comicType,
|
||||||
|
downloadedChapters: comic.downloadedChapters,
|
||||||
|
createdAt: comic.createdAt,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
return comic.downloadedChapters
|
return comic.downloadedChapters
|
||||||
.contains(comic.chapters!.ids.elementAt(ep - 1));
|
.contains((chapters ?? comic.chapters)!.ids.elementAtOrNull(ep - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DownloadTask> downloadingTasks = [];
|
List<DownloadTask> downloadingTasks = [];
|
||||||
|
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:venera/components/components.dart';
|
import 'package:venera/components/components.dart';
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
import 'package:venera/foundation/appdata.dart';
|
import 'package:venera/foundation/appdata.dart';
|
||||||
|
import 'package:venera/foundation/comic_type.dart';
|
||||||
import 'package:venera/foundation/local.dart';
|
import 'package:venera/foundation/local.dart';
|
||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/pages/comic_details_page/comic_page.dart';
|
import 'package:venera/pages/comic_details_page/comic_page.dart';
|
||||||
@@ -304,7 +305,9 @@ class _LocalComicsPageState extends State<LocalComicsPage> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
(c as LocalComic).read();
|
// prevent dirty data
|
||||||
|
var comic = LocalManager().find(c.id, ComicType(c.sourceKey.hashCode))!;
|
||||||
|
comic.read();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
menuBuilder: (c) {
|
menuBuilder: (c) {
|
||||||
|
@@ -26,7 +26,7 @@ class _ReaderImagesState extends State<_ReaderImages> {
|
|||||||
inProgress = true;
|
inProgress = true;
|
||||||
if (reader.type == ComicType.local ||
|
if (reader.type == ComicType.local ||
|
||||||
(LocalManager()
|
(LocalManager()
|
||||||
.isDownloaded(reader.cid, reader.type, reader.chapter))) {
|
.isDownloaded(reader.cid, reader.type, reader.chapter, reader.widget.chapters))) {
|
||||||
try {
|
try {
|
||||||
var images = await LocalManager()
|
var images = await LocalManager()
|
||||||
.getImages(reader.cid, reader.type, reader.chapter);
|
.getImages(reader.cid, reader.type, reader.chapter);
|
||||||
|
@@ -115,7 +115,7 @@ class _ReaderState extends State<Reader>
|
|||||||
|
|
||||||
String get cid => widget.cid;
|
String get cid => widget.cid;
|
||||||
|
|
||||||
String get eid => widget.chapters?.ids.elementAt(chapter - 1) ?? '0';
|
String get eid => widget.chapters?.ids.elementAtOrNull(chapter - 1) ?? '0';
|
||||||
|
|
||||||
List<String>? images;
|
List<String>? images;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user