Skip to content

Commit

Permalink
fix 'try external video player' information
Browse files Browse the repository at this point in the history
the idea to show some additional information about how to play a video
in case the thumbnail could not be generated was good -
however, the detection was just wrong :)

this pr tracks correctly if a thumbnail is a real video thumbnail
or just a placeholder -
in the latter case, the information of #1941 is shown
  • Loading branch information
r10s committed Nov 24, 2023
1 parent 55c4d5c commit 05ae213
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion deltachat-ios/Chat/Views/Cells/ImageTextCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ImageTextCell: BaseMessageCell {
imageView.clipsToBounds = true
return imageView
}()
var contentImageIsPlaceholder: Bool = true

/// The play button view to display on video messages.
open lazy var playButtonView: PlayButtonView = {
Expand Down Expand Up @@ -51,6 +52,7 @@ class ImageTextCell: BaseMessageCell {
topCompactView = msg.quoteText == nil ? true : false
isTransparent = msg.type == DC_MSG_STICKER
topLabel.isHidden = msg.type == DC_MSG_STICKER
contentImageIsPlaceholder = true
tag = msg.id

if let url = msg.fileURL,
Expand All @@ -61,6 +63,7 @@ class ImageTextCell: BaseMessageCell {
green: 255,
blue: 255),
size: CGSize(width: 500, height: 500)))
contentImageIsPlaceholder = false
playButtonView.isHidden = true
accessibilityLabel = msg.type == DC_MSG_GIF ? String.localized("gif") : String.localized("image")
setAspectRatioFor(message: msg)
Expand All @@ -69,6 +72,7 @@ class ImageTextCell: BaseMessageCell {
accessibilityLabel = String.localized("video")
if let image = ThumbnailCache.shared.restoreImage(key: url.absoluteString) {
contentImageView.image = image
contentImageIsPlaceholder = false
setAspectRatioFor(message: msg, with: image, isPlaceholder: false)
} else {
// no image in cache
Expand All @@ -84,6 +88,7 @@ class ImageTextCell: BaseMessageCell {
DispatchQueue.main.async { [weak self] in
if msg.id == self?.tag {
self?.contentImageView.image = thumbnailImage
self?.contentImageIsPlaceholder = false
ThumbnailCache.shared.storeImage(image: thumbnailImage, key: url.absoluteString)
}
}
Expand All @@ -103,7 +108,7 @@ class ImageTextCell: BaseMessageCell {

@objc func onImageTapped() {
if let tableView = self.superview as? UITableView, let indexPath = tableView.indexPath(for: self) {
baseDelegate?.imageTapped(indexPath: indexPath, previewError: imageView?.image == nil)
baseDelegate?.imageTapped(indexPath: indexPath, previewError: contentImageIsPlaceholder)
}
}

Expand Down Expand Up @@ -236,6 +241,7 @@ class ImageTextCell: BaseMessageCell {
super.prepareForReuse()
contentImageView.image = nil
contentImageView.sd_cancelCurrentImageLoad()
contentImageIsPlaceholder = true
tag = -1
}
}

0 comments on commit 05ae213

Please sign in to comment.