Fix preview when forwarding from Saved Messages

This commit is contained in:
Ilya Laktyushin 2021-11-11 21:35:11 +04:00
parent 49f272be5b
commit 383b555437
3 changed files with 13 additions and 15 deletions

View File

@ -59,7 +59,7 @@ public final class TelegramThemeSettings: Codable, Equatable {
self.baseTheme = TelegramBaseTheme(rawValue: try container.decode(Int32.self, forKey: "baseTheme")) ?? .classic
self.accentColor = UInt32(bitPattern: try container.decode(Int32.self, forKey: "accent"))
self.outgoingAccentColor = (try container.decodeIfPresent(Int32.self, forKey: "outgoingAccent")).flatMap { UInt32(bitPattern: $0) }
let messageColors = try container.decode([Int32].self, forKey: "messageColors")
let messageColors = try container.decodeIfPresent([Int32].self, forKey: "messageColors") ?? []
if !messageColors.isEmpty {
self.messageColors = messageColors.map(UInt32.init(bitPattern:))
} else {
@ -69,7 +69,7 @@ public final class TelegramThemeSettings: Codable, Equatable {
self.messageColors = []
}
}
self.animateMessageColors = try container.decode(Int32.self, forKey: "animateMessageColors") != 0
self.animateMessageColors = (try container.decodeIfPresent(Int32.self, forKey: "animateMessageColors") ?? 0) != 0
self.wallpaper = (try container.decodeIfPresent(TelegramWallpaperNativeCodable.self, forKey: "wallpaper"))?.value
}

View File

@ -5753,8 +5753,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
uniquePeerIds.insert(author.id)
}
if message.id.peerId == accountPeerId && author.id == accountPeerId {
if message.id.peerId == accountPeerId && message.forwardInfo == nil {
} else {
hasNotOwnMessages = true
}
@ -12042,13 +12041,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var hasNotOwnMessages = false
for message in messages {
if let author = message.effectiveAuthor {
if message.id.peerId == accountPeerId && author.id == accountPeerId {
if message.id.peerId == accountPeerId && message.forwardInfo == nil {
} else {
hasNotOwnMessages = true
}
}
}
if case .peer(peerId) = strongSelf.chatLocation, strongSelf.parentController == nil, !isPinnedMessages {
strongSelf.updateChatPresentationInterfaceState(animated: false, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedForwardMessageIds(messages.map { $0.id }).withUpdatedForwardOptionsState(ChatInterfaceForwardOptionsState(hideNames: !hasNotOwnMessages, hideCaptions: false, unhideNamesOnCaptionChange: false)).withoutSelectionState() }).updatedSearch(nil) })

View File

@ -281,11 +281,9 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
})
var hideNames = options.hideNames
if let author = message.effectiveAuthor {
if message.id.peerId == accountPeer.id && author.id == accountPeer.id {
if message.id.peerId == accountPeer.id && message.forwardInfo == nil {
hideNames = true
}
}
var messageText = message.text
var messageMedia = message.media
@ -309,8 +307,11 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
}
}
var forwardInfo = message.forwardInfo
if forwardInfo == nil {
var forwardInfo: MessageForwardInfo?
if let existingForwardInfo = message.forwardInfo {
forwardInfo = MessageForwardInfo(author: existingForwardInfo.author, source: existingForwardInfo.source, sourceMessageId: nil, date: 0, authorSignature: nil, psaType: nil, flags: [])
}
else {
forwardInfo = MessageForwardInfo(author: message.author, source: nil, sourceMessageId: nil, date: 0, authorSignature: nil, psaType: nil, flags: [])
}
if hideNames && !hasDice {