move the CheckDownloadStatus to filemessage model and only do to init
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
adc6c0491b
commit
37700e1a78
|
@ -443,11 +443,18 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
// so setting numChunks correctly shouldn't matter
|
||||
this.downloadInit(fileKey, 1);
|
||||
}
|
||||
// only update if different
|
||||
if (!this._downloads[fileKey]!.complete) {
|
||||
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
||||
this._downloads[fileKey]!.downloadedTo = finalPath;
|
||||
this._downloads[fileKey]!.complete = true;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
bool downloadKnown(String fileKey) {
|
||||
return this._downloads.containsKey(fileKey);
|
||||
}
|
||||
|
||||
bool downloadActive(String fileKey) {
|
||||
return this._downloads.containsKey(fileKey) && !this._downloads[fileKey]!.interrupted;
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:cwtch/widgets/messagerow.dart';
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../main.dart';
|
||||
import '../../model.dart';
|
||||
|
||||
class FileMessage extends Message {
|
||||
|
@ -29,6 +30,13 @@ class FileMessage extends Message {
|
|||
String rootHash = shareObj['h'] as String;
|
||||
String nonce = shareObj['n'] as String;
|
||||
int fileSize = shareObj['s'] as int;
|
||||
String fileKey = rootHash + "." + nonce;
|
||||
|
||||
if (metadata.attributes["file-downloaded"] == "true") {
|
||||
if (!Provider.of<ProfileInfoState>(context).downloadKnown(fileKey)) {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, fileKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (!validHash(rootHash, nonce)) {
|
||||
return MessageRow(MalformedBubble());
|
||||
|
|
|
@ -53,10 +53,6 @@ class FileBubbleState extends State<FileBubble> {
|
|||
var downloadComplete = Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
||||
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(widget.fileKey());
|
||||
|
||||
/*if (flagStarted && !downloadInterrupted) {
|
||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CheckDownloadStatus(Provider.of<ProfileInfoState>(context, listen: false).onion, widget.fileKey());
|
||||
}*/
|
||||
|
||||
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey());
|
||||
if (downloadComplete) {
|
||||
var lpath = path!.toLowerCase();
|
||||
|
|
Loading…
Reference in New Issue