Merge pull request 'fileCPU' (#276) from fileCPU into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #276
This commit is contained in:
commit
66aa9ef00d
|
@ -443,10 +443,17 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
// so setting numChunks correctly shouldn't matter
|
||||
this.downloadInit(fileKey, 1);
|
||||
}
|
||||
this._downloads[fileKey]!.timeEnd = DateTime.now();
|
||||
this._downloads[fileKey]!.downloadedTo = finalPath;
|
||||
this._downloads[fileKey]!.complete = true;
|
||||
notifyListeners();
|
||||
// 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) {
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -45,18 +45,14 @@ class FileBubbleState extends State<FileBubble> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var fromMe = Provider.of<MessageMetadata>(context).senderHandle == Provider.of<ProfileInfoState>(context).onion;
|
||||
var fromMe = Provider.of<MessageMetadata>(context, listen: false).senderHandle == Provider.of<ProfileInfoState>(context).onion;
|
||||
var flagStarted = Provider.of<MessageMetadata>(context).attributes["file-downloaded"] == "true";
|
||||
var borderRadiousEh = 15.0;
|
||||
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
||||
var showFileSharing = Provider.of<Settings>(context, listen: false).isExperimentEnabled(FileSharingExperiment);
|
||||
var prettyDate = DateFormat.yMd(Platform.localeName).add_jm().format(Provider.of<MessageMetadata>(context).timestamp);
|
||||
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