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,10 +443,17 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
// so setting numChunks correctly shouldn't matter
|
// so setting numChunks correctly shouldn't matter
|
||||||
this.downloadInit(fileKey, 1);
|
this.downloadInit(fileKey, 1);
|
||||||
}
|
}
|
||||||
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
// only update if different
|
||||||
this._downloads[fileKey]!.downloadedTo = finalPath;
|
if (!this._downloads[fileKey]!.complete) {
|
||||||
this._downloads[fileKey]!.complete = true;
|
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
||||||
notifyListeners();
|
this._downloads[fileKey]!.downloadedTo = finalPath;
|
||||||
|
this._downloads[fileKey]!.complete = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool downloadKnown(String fileKey) {
|
||||||
|
return this._downloads.containsKey(fileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool downloadActive(String fileKey) {
|
bool downloadActive(String fileKey) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:cwtch/widgets/messagerow.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../../main.dart';
|
||||||
import '../../model.dart';
|
import '../../model.dart';
|
||||||
|
|
||||||
class FileMessage extends Message {
|
class FileMessage extends Message {
|
||||||
|
@ -29,6 +30,13 @@ class FileMessage extends Message {
|
||||||
String rootHash = shareObj['h'] as String;
|
String rootHash = shareObj['h'] as String;
|
||||||
String nonce = shareObj['n'] as String;
|
String nonce = shareObj['n'] as String;
|
||||||
int fileSize = shareObj['s'] as int;
|
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)) {
|
if (!validHash(rootHash, nonce)) {
|
||||||
return MessageRow(MalformedBubble());
|
return MessageRow(MalformedBubble());
|
||||||
|
|
|
@ -53,10 +53,6 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
var downloadComplete = Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
var downloadComplete = Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
||||||
var downloadInterrupted = Provider.of<ProfileInfoState>(context).downloadInterrupted(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());
|
var path = Provider.of<ProfileInfoState>(context).downloadFinalPath(widget.fileKey());
|
||||||
if (downloadComplete) {
|
if (downloadComplete) {
|
||||||
var lpath = path!.toLowerCase();
|
var lpath = path!.toLowerCase();
|
||||||
|
|
Loading…
Reference in New Issue