Properly handle image experiment flags when showing sender side images
This commit is contained in:
parent
88a8ac8cca
commit
4ea0d4261c
|
@ -92,10 +92,16 @@ 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;
|
var isImagePreview = false;
|
||||||
if (downloadComplete && path != null) {
|
if (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")) {
|
||||||
|
isImagePreview = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (downloadComplete && path != null) {
|
||||||
|
if (isImagePreview) {
|
||||||
if (myFile == null || myFile?.path != path) {
|
if (myFile == null || myFile?.path != path) {
|
||||||
setState(() {
|
setState(() {
|
||||||
myFile = new File(path!);
|
myFile = new File(path!);
|
||||||
|
@ -114,8 +120,6 @@ 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...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,10 +142,13 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't preview a non downloaded file...
|
// if we should show a preview i.e. we are in a quote bubble
|
||||||
if (showImages && previewable) {
|
// 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);
|
return getPreview(context);
|
||||||
} else if (showFileSharing && (previewable || (widget.isPreview && myFile == null))) {
|
} else if (showFileSharing && widget.isPreview) {
|
||||||
|
// otherwise just show a summary...
|
||||||
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),
|
||||||
|
@ -165,9 +172,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
|
|
||||||
if (!showFileSharing) {
|
if (!showFileSharing) {
|
||||||
wdgDecorations = Text('\u202F');
|
wdgDecorations = Text('\u202F');
|
||||||
} else if (fromMe) {
|
} else if ((fromMe || downloadComplete) && path != null) {
|
||||||
wdgDecorations = Text('\u202F');
|
|
||||||
} else if (downloadComplete && path != null) {
|
|
||||||
// in this case, whatever marked download.complete would have also set the path
|
// in this case, whatever marked download.complete would have also set the path
|
||||||
if (myFile != null && Provider.of<Settings>(context).shouldPreview(path)) {
|
if (myFile != null && Provider.of<Settings>(context).shouldPreview(path)) {
|
||||||
isPreview = true;
|
isPreview = true;
|
||||||
|
@ -181,6 +186,8 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
pop(context, myFile!, widget.nameSuggestion);
|
pop(context, myFile!, widget.nameSuggestion);
|
||||||
},
|
},
|
||||||
)));
|
)));
|
||||||
|
} else if (fromMe) {
|
||||||
|
wdgDecorations = Text('\u202F');
|
||||||
} else {
|
} else {
|
||||||
wdgDecorations = Visibility(
|
wdgDecorations = Visibility(
|
||||||
visible: widget.interactive, child: SelectableText(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)));
|
visible: widget.interactive, child: SelectableText(AppLocalizations.of(context)!.fileSavedTo + ': ' + path + '\u202F', style: Provider.of<Settings>(context).scaleFonts(defaultTextStyle)));
|
||||||
|
|
Loading…
Reference in New Issue