Fix Sender Preview for Image Files
This commit is contained in:
parent
e0546eb502
commit
0eb1b95811
|
@ -75,6 +75,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
var flagStarted = Provider.of<MessageMetadata>(context).attributes["file-downloaded"] == "true";
|
var flagStarted = Provider.of<MessageMetadata>(context).attributes["file-downloaded"] == "true";
|
||||||
var borderRadius = 15.0;
|
var borderRadius = 15.0;
|
||||||
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
|
||||||
|
var showImages = Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment);
|
||||||
DateTime messageDate = Provider.of<MessageMetadata>(context).timestamp;
|
DateTime messageDate = Provider.of<MessageMetadata>(context).timestamp;
|
||||||
|
|
||||||
var metadata = Provider.of<MessageMetadata>(context);
|
var metadata = Provider.of<MessageMetadata>(context);
|
||||||
|
@ -91,13 +92,13 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
var downloadComplete = (fromMe && path != null) || Provider.of<ProfileInfoState>(context).downloadComplete(widget.fileKey());
|
var downloadComplete = (fromMe && path != null) || 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());
|
||||||
|
|
||||||
|
var previewable = widget.isPreview && myFile != null;
|
||||||
if (downloadComplete && path != null) {
|
if (downloadComplete && path != null) {
|
||||||
var lpath = path.toLowerCase();
|
var lpath = path.toLowerCase();
|
||||||
if (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")) {
|
if (lpath.endsWith(".jpg") || lpath.endsWith(".jpeg") || lpath.endsWith(".png") || lpath.endsWith(".gif") || lpath.endsWith(".webp") || lpath.endsWith(".bmp")) {
|
||||||
if (myFile == null || myFile?.path != path) {
|
if (myFile == null || myFile?.path != path) {
|
||||||
setState(() {
|
setState(() {
|
||||||
myFile = new File(path!);
|
myFile = new File(path!);
|
||||||
|
|
||||||
// reset
|
// reset
|
||||||
if (myFile?.existsSync() == false) {
|
if (myFile?.existsSync() == false) {
|
||||||
myFile = null;
|
myFile = null;
|
||||||
|
@ -113,6 +114,8 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
Provider.of<FlwtchState>(context).cwtch.SetMessageAttribute(metadata.profileOnion, metadata.conversationIdentifier, 0, metadata.messageID, "file-missing", "false");
|
Provider.of<FlwtchState>(context).cwtch.SetMessageAttribute(metadata.profileOnion, metadata.conversationIdentifier, 0, metadata.messageID, "file-missing", "false");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (myFile != null && fromMe) {
|
||||||
|
previewable = true; // allow previewing of images...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,9 +139,9 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't preview a non downloaded file...
|
// we don't preview a non downloaded file...
|
||||||
if (widget.isPreview && myFile != null) {
|
if (showImages && previewable) {
|
||||||
return getPreview(context);
|
return getPreview(context);
|
||||||
} else if (widget.isPreview && myFile == null) {
|
} else if (showFileSharing && (previewable || (widget.isPreview && myFile == null))) {
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromMeTextColor),
|
Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of<Settings>(context).theme.messageFromMeTextColor),
|
||||||
|
|
Loading…
Reference in New Issue