Various fixes

This commit is contained in:
Ilya Laktyushin 2024-03-26 12:05:10 +04:00
parent fb74fa7332
commit 43cd8a4144
6 changed files with 23 additions and 10 deletions

View File

@ -231,7 +231,11 @@ final class ChatListNoticeItemNode: ItemListRevealOptionsItemNode {
let title: String
let text: String
if peers.count == 1, let peer = peers.first {
title = item.strings.ChatList_BirthdaySingleTitle(peer.compactDisplayTitle).string
var peerName = peer.compactDisplayTitle
if peerName.count > 20 {
peerName = peerName.prefix(20).trimmingCharacters(in: .whitespacesAndNewlines) + "\u{2026}"
}
title = item.strings.ChatList_BirthdaySingleTitle(peerName).string
text = item.strings.ChatList_BirthdaySingleText
} else {
title = item.strings.ChatList_BirthdayMultipleTitle(Int32(peers.count))

View File

@ -862,6 +862,9 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
if let file = content.file, !file.isAnimated, file.isVideo {
canFullscreen = true
}
if content.type == "photo", let _ = content.image {
canEdit = true
}
}
}

View File

@ -161,7 +161,7 @@ public func stringForCompactBirthday(_ birthday: TelegramBirthday, strings: Pres
let calendar = Calendar.current
if let birthDate = calendar.date(from: dateComponents) {
if let age = calendar.dateComponents([.year], from: birthDate, to: Date()).year {
if let age = calendar.dateComponents([.year], from: birthDate, to: Date()).year, age > 0 {
components.append("(\(strings.UserInfo_Age(Int32(age))))")
}
}

View File

@ -235,6 +235,12 @@ private final class TokenNode: ASDisplayNode {
})
}
self.titleNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
} else {
if isSelected {
self.selectedBackgroundNode.alpha = 1.0
} else {
self.selectedBackgroundNode.alpha = 0.0
}
}
self.titleNode.attributedText = NSAttributedString(string: token.title, font: Font.regular(14.0), textColor: self.isSelected ? self.theme.selectedTextColor : self.theme.primaryTextColor)

View File

@ -2696,16 +2696,10 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
if let self {
if value {
if let data = self.data?.cachedData as? CachedUserData {
if data.birthday == nil {
if data.birthday == nil && self.state.updatingBirthDate == nil {
self.state = self.state.withUpdatingBirthDate(TelegramBirthday(day: 1, month: 1, year: nil))
} else {
self.state = self.state.withUpdatingBirthDate(nil)
}
}
} else {
if self.state.updatingBirthDate != .some(nil) {
self.state = self.state.withUpdatingBirthDate(nil)
}
}
self.state = self.state.withIsEditingBirthDate(value)
@ -11070,7 +11064,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
hasBirthdayToday = true
}
if hasBirthdayToday {
if hasBirthdayToday, let age = ageForBirthday(birthday), age > 0 {
Queue.mainQueue().after(0.3) {
var birthdayItemFrame: CGRect?
if let section = self.regularSections[InfoSection.peerInfo] {

View File

@ -1301,6 +1301,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
mediaReference = AnyMediaReference.standalone(media: image)
} else if let file = media as? TelegramMediaFile {
mediaReference = AnyMediaReference.standalone(media: file)
} else if let webpage = media as? TelegramMediaWebpage, case let .Loaded(content) = webpage.content {
if let image = content.image {
mediaReference = AnyMediaReference.standalone(media: image)
} else if let file = content.file {
mediaReference = AnyMediaReference.standalone(media: file)
}
}
}