Fix Image Previews + Make Invitations the correct Size #821

Merged
sarah merged 4 commits from fix-images into trunk 2024-02-13 04:00:17 +00:00
1 changed files with 6 additions and 3 deletions
Showing only changes of commit 0eb1b95811 - Show all commits

View File

@ -75,6 +75,7 @@ class FileBubbleState extends State<FileBubble> {
var flagStarted = Provider.of<MessageMetadata>(context).attributes["file-downloaded"] == "true";
var borderRadius = 15.0;
var showFileSharing = Provider.of<Settings>(context).isExperimentEnabled(FileSharingExperiment);
var showImages = Provider.of<Settings>(context).isExperimentEnabled(ImagePreviewsExperiment);
DateTime messageDate = Provider.of<MessageMetadata>(context).timestamp;
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 downloadInterrupted = Provider.of<ProfileInfoState>(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<FileBubble> {
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...
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<Settings>(context).theme.messageFromMeTextColor),