diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index 2e790cab..02605c3a 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -75,6 +75,7 @@ class FileBubbleState extends State { var flagStarted = Provider.of(context).attributes["file-downloaded"] == "true"; var borderRadius = 15.0; var showFileSharing = Provider.of(context).isExperimentEnabled(FileSharingExperiment); + var showImages = Provider.of(context).isExperimentEnabled(ImagePreviewsExperiment); DateTime messageDate = Provider.of(context).timestamp; var metadata = Provider.of(context); @@ -91,13 +92,13 @@ class FileBubbleState extends State { var downloadComplete = (fromMe && path != null) || Provider.of(context).downloadComplete(widget.fileKey()); var downloadInterrupted = Provider.of(context).downloadInterrupted(widget.fileKey()); + var previewable = widget.isPreview && myFile != null; if (downloadComplete && path != null) { var lpath = path.toLowerCase(); 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) { setState(() { myFile = new File(path!); - // reset if (myFile?.existsSync() == false) { myFile = null; @@ -113,6 +114,8 @@ class FileBubbleState extends State { Provider.of(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 { } // we don't preview a non downloaded file... - if (widget.isPreview && myFile != null) { + if (showImages && previewable) { return getPreview(context); - } else if (widget.isPreview && myFile == null) { + } else if (showFileSharing && (previewable || (widget.isPreview && myFile == null))) { return Row( children: [ Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of(context).theme.messageFromMeTextColor),