Various fixes

This commit is contained in:
Ilya Laktyushin 2024-12-28 23:06:41 +04:00
parent 7efcdb4b8e
commit 3bbb677b0d
8 changed files with 14 additions and 44 deletions

View File

@ -13539,11 +13539,6 @@ Sorry for the inconvenience.";
"Gift.View.UpgradeForFree" = "Upgrade for Free"; "Gift.View.UpgradeForFree" = "Upgrade for Free";
"Gift.View.KeepUpgradeOrConvertDescription" = "You can keep this gift, upgrade it, or sell it for %@. [More About Stars >]()"; "Gift.View.KeepUpgradeOrConvertDescription" = "You can keep this gift, upgrade it, or sell it for %@. [More About Stars >]()";
"PeerInfo.VerificationInfo.Bot" = "This bot is verified as official by the representatives of Telegram.";
"PeerInfo.VerificationInfo.Channel" = "This channel is verified as official by the representatives of Telegram.";
"PeerInfo.VerificationInfo.Group" = "This group is verified as official by the representatives of Telegram.";
"PeerInfo.VerificationInfo.URL" = "https://telegram.org/verify";
"ChatList.ToastFolderMutedV2" = "All chats in {folder} are now muted"; "ChatList.ToastFolderMutedV2" = "All chats in {folder} are now muted";
"ChatList.ToastFolderUnmutedV2" = "All chats in {folder} are now unmuted"; "ChatList.ToastFolderUnmutedV2" = "All chats in {folder} are now unmuted";
"ChatList.AddedToFolderTooltipV2" = "{chat} has been added to folder {folder}"; "ChatList.AddedToFolderTooltipV2" = "{chat} has been added to folder {folder}";

View File

@ -1096,7 +1096,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, starsPrice)._tuple, body: bodyAttributes, argumentAttributes: attributes) attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Sent(authorName, starsPrice)._tuple, body: bodyAttributes, argumentAttributes: attributes)
} }
} }
case let .starGiftUnique(gift, isUpgrade, isTransferred, _, _, _, _): case let .starGiftUnique(gift, isUpgrade, _, _, _, _, _):
if case let .unique(gift) = gift { if case let .unique(gift) = gift {
if !forAdditionalServiceMessage { if !forAdditionalServiceMessage {
attributedString = NSAttributedString(string: "\(gift.title) #\(gift.number)", font: titleFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: "\(gift.title) #\(gift.number)", font: titleFont, textColor: primaryTextColor)
@ -1113,7 +1113,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds) let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Upgrade(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes) attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Upgrade(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
} }
} else if isTransferred { } else {
if message.author?.id == accountPeerId { if message.author?.id == accountPeerId {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_TransferYou, font: titleFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: strings.Notification_StarsGift_TransferYou, font: titleFont, textColor: primaryTextColor)
} else { } else {

View File

@ -557,6 +557,7 @@ public final class ButtonComponent: Component {
} else { } else {
shimmeringTransition = .immediate shimmeringTransition = .immediate
shimmeringView = ButtonShimmeringView(frame: .zero) shimmeringView = ButtonShimmeringView(frame: .zero)
self.shimmeringView = shimmeringView
self.insertSubview(shimmeringView, at: 0) self.insertSubview(shimmeringView, at: 0)
} }
shimmeringView.update(size: availableSize, background: component.background, cornerRadius: component.background.cornerRadius, transition: shimmeringTransition) shimmeringView.update(size: availableSize, background: component.background, cornerRadius: component.background.cornerRadius, transition: shimmeringTransition)

View File

@ -462,7 +462,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
buttonTitle = item.presentationData.strings.Notification_PremiumPrize_View buttonTitle = item.presentationData.strings.Notification_PremiumPrize_View
hasServiceMessage = false hasServiceMessage = false
} }
case let .starGift(gift, convertStars, giftText, giftEntities, _, savedToProfile, converted, upgraded, _, upgradeStars, isRefunded, _): case let .starGift(gift, convertStars, giftText, giftEntities, _, savedToProfile, converted, upgraded, canUpgrade, upgradeStars, isRefunded, _):
if case let .generic(gift) = gift { if case let .generic(gift) = gift {
isStarGift = true isStarGift = true
let authorName = item.message.author.flatMap { EnginePeer($0) }?.compactDisplayTitle ?? "" let authorName = item.message.author.flatMap { EnginePeer($0) }?.compactDisplayTitle ?? ""
@ -486,7 +486,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
text = item.presentationData.strings.Notification_StarGift_Subtitle_Converted(item.presentationData.strings.Notification_StarGift_Subtitle_Converted_Stars(Int32(convertStars ?? 0))).string text = item.presentationData.strings.Notification_StarGift_Subtitle_Converted(item.presentationData.strings.Notification_StarGift_Subtitle_Converted_Stars(Int32(convertStars ?? 0))).string
} else if upgradeStars != nil { } else if upgradeStars != nil {
text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade
} else if isSelfGift { } else if isSelfGift && canUpgrade {
text = item.presentationData.strings.Notification_StarsGift_Subtitle_Self text = item.presentationData.strings.Notification_StarsGift_Subtitle_Self
} else if savedToProfile { } else if savedToProfile {
if let convertStars { if let convertStars {

View File

@ -476,6 +476,7 @@ final class GiftOptionsScreenComponent: Component {
let bottomContentInset: CGFloat = 24.0 let bottomContentInset: CGFloat = 24.0
let sideInset: CGFloat = 16.0 + environment.safeInsets.left let sideInset: CGFloat = 16.0 + environment.safeInsets.left
let sectionSpacing: CGFloat = 24.0 let sectionSpacing: CGFloat = 24.0
let headerSideInset: CGFloat = 24.0 + environment.safeInsets.left
let _ = bottomContentInset let _ = bottomContentInset
let _ = sectionSpacing let _ = sectionSpacing
@ -620,7 +621,7 @@ final class GiftOptionsScreenComponent: Component {
horizontalAlignment: .center horizontalAlignment: .center
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: availableSize.width, height: 100.0) containerSize: CGSize(width: availableSize.width - headerSideInset * 2.0, height: 100.0)
) )
if let premiumTitleView = self.premiumTitle.view { if let premiumTitleView = self.premiumTitle.view {
if premiumTitleView.superview == nil { if premiumTitleView.superview == nil {
@ -676,7 +677,7 @@ final class GiftOptionsScreenComponent: Component {
} }
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: availableSize.width, height: 1000.0) containerSize: CGSize(width: availableSize.width - headerSideInset * 2.0, height: 1000.0)
) )
let premiumDescriptionFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - premiumDescriptionSize.width) / 2.0), y: contentHeight), size: premiumDescriptionSize) let premiumDescriptionFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - premiumDescriptionSize.width) / 2.0), y: contentHeight), size: premiumDescriptionSize)
if let premiumDescriptionView = self.premiumDescription.view { if let premiumDescriptionView = self.premiumDescription.view {
@ -818,7 +819,7 @@ final class GiftOptionsScreenComponent: Component {
horizontalAlignment: .center horizontalAlignment: .center
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: availableSize.width, height: 100.0) containerSize: CGSize(width: availableSize.width - headerSideInset * 2.0, height: 100.0)
) )
if let starsTitleView = self.starsTitle.view { if let starsTitleView = self.starsTitle.view {
if starsTitleView.superview == nil { if starsTitleView.superview == nil {
@ -864,7 +865,7 @@ final class GiftOptionsScreenComponent: Component {
} }
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: availableSize.width, height: 1000.0) containerSize: CGSize(width: availableSize.width - headerSideInset * 2.0, height: 1000.0)
) )
let starsDescriptionFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - starsDescriptionSize.width) / 2.0), y: contentHeight), size: starsDescriptionSize) let starsDescriptionFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - starsDescriptionSize.width) / 2.0), y: contentHeight), size: starsDescriptionSize)
if let starsDescriptionView = self.starsDescription.view { if let starsDescriptionView = self.starsDescription.view {

View File

@ -1790,7 +1790,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
context: AccountContext, context: AccountContext,
subject: GiftViewScreen.Subject, subject: GiftViewScreen.Subject,
forceDark: Bool = false, forceDark: Bool = false,
updateSavedToProfile: ((Bool) -> Void)? = nil, updateSavedToProfile: ((EngineMessage.Id, Bool) -> Void)? = nil,
convertToStars: (() -> Void)? = nil, convertToStars: (() -> Void)? = nil,
transferGift: ((Bool, EnginePeer.Id) -> Void)? = nil, transferGift: ((Bool, EnginePeer.Id) -> Void)? = nil,
upgradeGift: ((Int64?, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)? = nil upgradeGift: ((Int64?, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)? = nil
@ -1890,7 +1890,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
} }
if let updateSavedToProfile { if let updateSavedToProfile {
updateSavedToProfile(added) updateSavedToProfile(messageId, added)
} else { } else {
let _ = (context.engine.payments.updateStarGiftAddedToProfile(messageId: messageId, added: added) let _ = (context.engine.payments.updateStarGiftAddedToProfile(messageId: messageId, added: added)
|> deliverOnMainQueue).startStandalone() |> deliverOnMainQueue).startStandalone()

View File

@ -1641,17 +1641,6 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {}) context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {})
} }
})) }))
} else if user.isVerified {
let description = presentationData.strings.PeerInfo_VerificationInfo_Bot
let attributedPrefix = NSMutableAttributedString(string: " ")
attributedPrefix.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .verification), range: NSMakeRange(0, 1))
items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: 800, text: description, attributedPrefix: attributedPrefix, useAccentLinkColor: false, linkAction: { action in
if case .tap = action, let navigationController = interaction.getController()?.navigationController as? NavigationController {
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: presentationData.strings.PeerInfo_VerificationInfo_URL, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {})
}
}))
} else if let botInfo = user.botInfo, botInfo.flags.contains(.worksWithGroups) { } else if let botInfo = user.botInfo, botInfo.flags.contains(.worksWithGroups) {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 7, text: presentationData.strings.Bot_AddToChat, color: .accent, action: { items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 7, text: presentationData.strings.Bot_AddToChat, color: .accent, action: {
interaction.openAddBotToGroup() interaction.openAddBotToGroup()
@ -1821,22 +1810,6 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {}) context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: url, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {})
} }
})) }))
} else if channel.isVerified {
let description: String
if case .group = channel.info {
description = presentationData.strings.PeerInfo_VerificationInfo_Group
} else {
description = presentationData.strings.PeerInfo_VerificationInfo_Channel
}
let attributedPrefix = NSMutableAttributedString(string: " ")
attributedPrefix.addAttribute(ChatTextInputAttributes.customEmoji, value: ChatTextInputTextCustomEmojiAttribute(interactivelySelectedFromPackId: nil, fileId: 0, file: nil, custom: .verification), range: NSMakeRange(0, 1))
items[currentPeerInfoSection]!.append(PeerInfoScreenCommentItem(id: 800, text: description, attributedPrefix: attributedPrefix, useAccentLinkColor: false, linkAction: { action in
if case .tap = action, let navigationController = interaction.getController()?.navigationController as? NavigationController {
context.sharedContext.openExternalUrl(context: context, urlContext: .generic, url: presentationData.strings.PeerInfo_VerificationInfo_URL, forceExternal: false, presentationData: presentationData, navigationController: navigationController, dismissInput: {})
}
}))
} }
if case .broadcast = channel.info { if case .broadcast = channel.info {

View File

@ -224,8 +224,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
let controller = GiftViewScreen( let controller = GiftViewScreen(
context: self.context, context: self.context,
subject: .profileGift(self.peerId, product), subject: .profileGift(self.peerId, product),
updateSavedToProfile: { [weak self] added in updateSavedToProfile: { [weak self] messageId, added in
guard let self, let messageId = product.messageId else { guard let self else {
return return
} }
self.profileGifts.updateStarGiftAddedToProfile(messageId: messageId, added: added) self.profileGifts.updateStarGiftAddedToProfile(messageId: messageId, added: added)