Various fixes

This commit is contained in:
Ilya Laktyushin
2018-12-03 19:47:49 +04:00
parent 9396d11675
commit 041464a293
48 changed files with 568 additions and 191 deletions

View File

@@ -668,7 +668,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
}
}
}
} else if let webpage = webpage, let automaticDownload = self.automaticDownload, automaticDownload, case let .Loaded(content) = webpage.content {
} else if let webpage = webpage, let automaticDownload = self.automaticDownload, automaticDownload, case .Loaded = webpage.content {
state = .play(bubbleTheme.mediaOverlayControlForegroundColor)
}
case .Local:
@@ -698,28 +698,23 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
state = .play(bubbleTheme.mediaOverlayControlForegroundColor)
}
}
if case .constrained = sizeCalculation {
if let file = media as? TelegramMediaFile, let duration = file.duration, !file.isAnimated {
let durationString = stringForDuration(duration)
badgeContent = .text(inset: 0.0, backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, shape: .round, text: NSAttributedString(string: durationString))
}
if let file = media as? TelegramMediaFile, let duration = file.duration, !file.isAnimated {
let durationString = stringForDuration(duration)
badgeContent = .text(inset: 0.0, backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, shape: .round, text: NSAttributedString(string: durationString))
}
case .Remote:
state = .download(bubbleTheme.mediaOverlayControlForegroundColor)
if let file = self.media as? TelegramMediaFile, let duration = file.duration, !file.isAnimated {
let durationString = stringForDuration(duration)
if case .constrained = sizeCalculation {
if isMediaStreamable(message: message, media: file) {
state = .play(bubbleTheme.mediaOverlayControlForegroundColor)
let durationString = stringForDuration(duration)
badgeContent = .mediaDownload(backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, duration: durationString, size: dataSizeString(file.size ?? 0))
mediaDownloadState = .remote
} else {
let durationString = stringForDuration(duration)
badgeContent = .text(inset: 0.0, backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, shape: .round, text: NSAttributedString(string: durationString))
}
} else {
let durationString = stringForDuration(duration)
if isMediaStreamable(message: message, media: file) {
state = .play(bubbleTheme.mediaOverlayControlForegroundColor)
badgeContent = .text(inset: 16.0, backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, shape: .round, text: NSAttributedString(string: durationString))
@@ -728,7 +723,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode {
badgeContent = .text(inset: 0.0, backgroundColor: bubbleTheme.mediaDateAndStatusFillColor, foregroundColor: bubbleTheme.mediaDateAndStatusTextColor, shape: .round, text: NSAttributedString(string: durationString))
}
}
} else if let webpage = webpage, let automaticDownload = self.automaticDownload, automaticDownload, case let .Loaded(content) = webpage.content {
} else if let webpage = webpage, let automaticDownload = self.automaticDownload, automaticDownload, case .Loaded = webpage.content {
state = .play(bubbleTheme.mediaOverlayControlForegroundColor)
}
}