Fix timestamp display for files in webpage preview

This commit is contained in:
Ilya Laktyushin
2021-05-05 17:42:02 +04:00
parent cb3ea323a1
commit f884d9586c

View File

@@ -412,17 +412,17 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
textString = string.attributedSubstring(from: NSMakeRange(0, 1000)) textString = string.attributedSubstring(from: NSMakeRange(0, 1000))
} }
var automaticPlayback = false
var skipStandardStatus = false
var isReplyThread = false var isReplyThread = false
if case .replyThread = chatLocation { if case .replyThread = chatLocation {
isReplyThread = true isReplyThread = true
} }
var imageMode = false var skipStandardStatus = false
var isImage = false
var isFile = false
var automaticPlayback = false
var textStatusType: ChatMessageDateAndStatusType? var textStatusType: ChatMessageDateAndStatusType?
var imageStatusType: ChatMessageDateAndStatusType? var imageStatusType: ChatMessageDateAndStatusType?
var additionalImageBadgeContent: ChatMessageInteractiveMediaBadgeContent? var additionalImageBadgeContent: ChatMessageInteractiveMediaBadgeContent?
@@ -430,62 +430,66 @@ final class ChatMessageAttachedContentNode: ASDisplayNode {
if let (media, flags) = mediaAndFlags { if let (media, flags) = mediaAndFlags {
if let file = media as? TelegramMediaFile { if let file = media as? TelegramMediaFile {
if file.mimeType == "application/x-tgtheme-ios", let size = file.size, size < 16 * 1024 { if file.mimeType == "application/x-tgtheme-ios", let size = file.size, size < 16 * 1024 {
imageMode = true isImage = true
} else if file.isInstantVideo { } else if file.isInstantVideo {
imageMode = true isImage = true
} else if file.isVideo { } else if file.isVideo {
imageMode = true isImage = true
} else if file.isSticker || file.isAnimatedSticker { } else if file.isSticker || file.isAnimatedSticker {
imageMode = true isImage = true
} else {
isFile = true
} }
} else if let _ = media as? TelegramMediaImage { } else if let _ = media as? TelegramMediaImage {
if !flags.contains(.preferMediaInline) { if !flags.contains(.preferMediaInline) {
imageMode = true isImage = true
} }
} else if let _ = media as? TelegramMediaWebFile { } else if let _ = media as? TelegramMediaWebFile {
imageMode = true isImage = true
} else if let _ = media as? WallpaperPreviewMedia { } else if let _ = media as? WallpaperPreviewMedia {
imageMode = true isImage = true
} }
} }
if preferMediaBeforeText { if preferMediaBeforeText {
imageMode = false isImage = false
} }
let statusInText = !imageMode let statusInText = !isImage
switch preparePosition { switch preparePosition {
case .linear(_, .None), .linear(_, .Neighbour(true, _, _)): case .linear(_, .None), .linear(_, .Neighbour(true, _, _)):
if let count = webpageGalleryMediaCount { if let count = webpageGalleryMediaCount {
additionalImageBadgeContent = .text(inset: 0.0, backgroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusFillColor, foregroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusTextColor, text: NSAttributedString(string: presentationData.strings.Items_NOfM("1", "\(count)").0)) additionalImageBadgeContent = .text(inset: 0.0, backgroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusFillColor, foregroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusTextColor, text: NSAttributedString(string: presentationData.strings.Items_NOfM("1", "\(count)").0))
skipStandardStatus = imageMode skipStandardStatus = isImage
} else if let mediaBadge = mediaBadge { } else if let mediaBadge = mediaBadge {
additionalImageBadgeContent = .text(inset: 0.0, backgroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusFillColor, foregroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusTextColor, text: NSAttributedString(string: mediaBadge)) additionalImageBadgeContent = .text(inset: 0.0, backgroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusFillColor, foregroundColor: presentationData.theme.theme.chat.message.mediaDateAndStatusTextColor, text: NSAttributedString(string: mediaBadge))
} else {
skipStandardStatus = isFile
} }
if !skipStandardStatus { if !skipStandardStatus {
if message.effectivelyIncoming(context.account.peerId) { if message.effectivelyIncoming(context.account.peerId) {
if imageMode { if isImage {
imageStatusType = .ImageIncoming imageStatusType = .ImageIncoming
} else { } else {
textStatusType = .BubbleIncoming textStatusType = .BubbleIncoming
} }
} else { } else {
if message.flags.contains(.Failed) { if message.flags.contains(.Failed) {
if imageMode { if isImage {
imageStatusType = .ImageOutgoing(.Failed) imageStatusType = .ImageOutgoing(.Failed)
} else { } else {
textStatusType = .BubbleOutgoing(.Failed) textStatusType = .BubbleOutgoing(.Failed)
} }
} else if (message.flags.isSending && !message.isSentOrAcknowledged) || attributes.updatingMedia != nil { } else if (message.flags.isSending && !message.isSentOrAcknowledged) || attributes.updatingMedia != nil {
if imageMode { if isImage {
imageStatusType = .ImageOutgoing(.Sending) imageStatusType = .ImageOutgoing(.Sending)
} else { } else {
textStatusType = .BubbleOutgoing(.Sending) textStatusType = .BubbleOutgoing(.Sending)
} }
} else { } else {
if imageMode { if isImage {
imageStatusType = .ImageOutgoing(.Sent(read: messageRead)) imageStatusType = .ImageOutgoing(.Sent(read: messageRead))
} else { } else {
textStatusType = .BubbleOutgoing(.Sent(read: messageRead)) textStatusType = .BubbleOutgoing(.Sent(read: messageRead))