diff --git a/lib/widgets/filebubble.dart b/lib/widgets/filebubble.dart index 02605c3a..2879d721 100644 --- a/lib/widgets/filebubble.dart +++ b/lib/widgets/filebubble.dart @@ -92,10 +92,16 @@ 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 isImagePreview = false; + if (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")) { + isImagePreview = true; + } + } + + if (downloadComplete && path != null) { + if (isImagePreview) { if (myFile == null || myFile?.path != path) { setState(() { myFile = new File(path!); @@ -114,8 +120,6 @@ 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... } } } @@ -138,10 +142,13 @@ class FileBubbleState extends State { } } - // we don't preview a non downloaded file... - if (showImages && previewable) { + // if we should show a preview i.e. we are in a quote bubble + // then do that here... + if (showImages && isImagePreview && widget.isPreview && myFile != null) { + // if the image exists then just show the image as a preview return getPreview(context); - } else if (showFileSharing && (previewable || (widget.isPreview && myFile == null))) { + } else if (showFileSharing && widget.isPreview) { + // otherwise just show a summary... return Row( children: [ Icon(CwtchIcons.attached_file_3, size: 32, color: Provider.of(context).theme.messageFromMeTextColor), @@ -165,9 +172,7 @@ class FileBubbleState extends State { if (!showFileSharing) { wdgDecorations = Text('\u202F'); - } else if (fromMe) { - wdgDecorations = Text('\u202F'); - } else if (downloadComplete && path != null) { + } else if ((fromMe || downloadComplete) && path != null) { // in this case, whatever marked download.complete would have also set the path if (myFile != null && Provider.of(context).shouldPreview(path)) { isPreview = true; @@ -181,6 +186,8 @@ class FileBubbleState extends State { pop(context, myFile!, widget.nameSuggestion); }, ))); + } else if (fromMe) { + wdgDecorations = Text('\u202F'); } else { wdgDecorations = Visibility( visible: widget.interactive, child: SelectableText(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F', style: Provider.of(context).scaleFonts(defaultTextStyle)));