Various improvements

This commit is contained in:
Ilya Laktyushin
2025-01-22 21:33:47 +04:00
parent 103b244216
commit 8164009fdb
4 changed files with 34 additions and 7 deletions

View File

@@ -1086,7 +1086,9 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
authorName = strings.Notification_StarsGift_UnknownUser
peerIds = []
}
if message.id.peerId == accountPeerId {
if message.id.peerId.isTelegramNotifications && senderId == nil {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_SentSomeone, font: titleFont, textColor: primaryTextColor)
} else if message.id.peerId == accountPeerId {
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Self_Bought(starsPrice)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
} else if message.author?.id == accountPeerId {
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_SentYou(starsPrice)._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
@@ -1111,15 +1113,17 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, starsPrice)._tuple, body: bodyAttributes, argumentAttributes: attributes)
}
}
case let .starGiftUnique(gift, isUpgrade, _, _, _, _, _, _, _, _):
case let .starGiftUnique(gift, isUpgrade, _, _, _, _, _, _, senderId, _):
if case let .unique(gift) = gift {
if !forAdditionalServiceMessage && !"".isEmpty {
attributedString = NSAttributedString(string: "\(gift.title) #\(gift.number)", font: titleFont, textColor: primaryTextColor)
} else if let messagePeer = message.peers[message.id.peerId] {
let peerName = EnginePeer(messagePeer).compactDisplayTitle
let peerIds: [(Int, EnginePeer.Id?)] = [(0, messagePeer.id)]
var peerName = EnginePeer(messagePeer).compactDisplayTitle
var peerIds: [(Int, EnginePeer.Id?)] = [(0, messagePeer.id)]
if isUpgrade {
if message.id.peerId == accountPeerId {
if message.id.peerId.isTelegramNotifications {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_UpgradeChannel, font: titleFont, textColor: primaryTextColor)
} else if message.id.peerId == accountPeerId {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_UpgradeSelf, font: titleFont, textColor: primaryTextColor)
} else if message.author?.id == accountPeerId {
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
@@ -1129,8 +1133,15 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Upgrade(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
}
} else {
if message.author?.id == accountPeerId {
if message.id.peerId.isTelegramNotifications && senderId == nil {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_SentSomeone, font: titleFont, textColor: primaryTextColor)
} else if message.author?.id == accountPeerId {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_TransferYou, font: titleFont, textColor: primaryTextColor)
} else if let senderId, let peer = message.peers[senderId] {
peerName = EnginePeer(peer).compactDisplayTitle
peerIds = [(0, senderId)]
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Transfer(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
} else {
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Transfer(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)