mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Fixed download speed display.
This commit is contained in:
@@ -509,7 +509,7 @@ class LocalManager with ChangeNotifier {
|
||||
var dir = Directory(FilePath.join(path, c.directory));
|
||||
dir.deleteIgnoreError(recursive: true);
|
||||
}
|
||||
// Deleting a local comic means that it's nolonger available, thus both favorite and history should be deleted.
|
||||
// Deleting a local comic means that it's no longer available, thus both favorite and history should be deleted.
|
||||
if (c.comicType == ComicType.local) {
|
||||
if (HistoryManager().find(c.id, c.comicType) != null) {
|
||||
HistoryManager().remove(c.id, c.comicType);
|
||||
|
@@ -139,13 +139,11 @@ class ImageDownloader {
|
||||
var buffer = <int>[];
|
||||
await for (var data in stream) {
|
||||
buffer.addAll(data);
|
||||
if (expectedBytes != null) {
|
||||
yield ImageDownloadProgress(
|
||||
currentBytes: buffer.length,
|
||||
totalBytes: expectedBytes,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (configs['onResponse'] is JSInvokable) {
|
||||
buffer = (configs['onResponse'] as JSInvokable)([buffer]);
|
||||
@@ -194,7 +192,7 @@ class ImageDownloader {
|
||||
class ImageDownloadProgress {
|
||||
final int currentBytes;
|
||||
|
||||
final int totalBytes;
|
||||
final int? totalBytes;
|
||||
|
||||
final Uint8List? imageBytes;
|
||||
|
||||
|
@@ -15,6 +15,15 @@ class DownloadingPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DownloadingPageState extends State<DownloadingPage> {
|
||||
DownloadTask? firstTask;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
firstTask = LocalManager().downloadingTasks.firstOrNull;
|
||||
firstTask?.addListener(update);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
LocalManager().addListener(update);
|
||||
@@ -24,10 +33,17 @@ class _DownloadingPageState extends State<DownloadingPage> {
|
||||
@override
|
||||
void dispose() {
|
||||
LocalManager().removeListener(update);
|
||||
firstTask?.removeListener(update);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void update() {
|
||||
var currentFirstTask = LocalManager().downloadingTasks.firstOrNull;
|
||||
if (currentFirstTask != firstTask) {
|
||||
firstTask?.removeListener(update);
|
||||
firstTask = currentFirstTask;
|
||||
firstTask?.addListener(update);
|
||||
}
|
||||
if(mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
|
Reference in New Issue
Block a user