Skip to content

Commit

Permalink
Merge pull request #1749 from nextcloud/check-nan-for-preview
Browse files Browse the repository at this point in the history
Fix potential crash on invalid preview size
  • Loading branch information
SystemKeeper authored Aug 9, 2024
2 parents d98b583 + bc4d26e commit 6fae87c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions NextcloudTalk/BaseChatTableViewCell+File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,17 @@ extension BaseChatTableViewCell {
self.filePreviewActivityIndicator?.isHidden = true
self.filePreviewActivityIndicator?.stopAnimating()

imageView.layer.borderColor = UIColor.secondarySystemFill.cgColor
imageView.layer.borderWidth = 1

let imageSize = CGSize(width: image.size.width * image.scale, height: image.size.height * image.scale)
let previewSize = BaseChatTableViewCell.getPreviewSize(from: imageSize, isMediaFile)

if !previewSize.width.isFinite || !previewSize.height.isFinite {
self.showFallbackIcon(for: message)
return
}

imageView.layer.borderColor = UIColor.secondarySystemFill.cgColor
imageView.layer.borderWidth = 1

self.filePreviewImageViewHeightConstraint?.constant = previewSize.height
self.filePreviewImageViewWidthConstraint?.constant = previewSize.width

Expand Down

0 comments on commit 6fae87c

Please sign in to comment.