Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Dec 28, 2024
1 parent 7efcdb4 commit 3bbb677
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 44 deletions.
5 changes: 0 additions & 5 deletions Telegram/Telegram-iOS/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -13539,11 +13539,6 @@ Sorry for the inconvenience.";
"Gift.View.UpgradeForFree" = "Upgrade for Free";
"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.ToastFolderUnmutedV2" = "All chats in {folder} are now unmuted";
"ChatList.AddedToFolderTooltipV2" = "{chat} has been added to folder {folder}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
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 !forAdditionalServiceMessage {
attributedString = NSAttributedString(string: "\(gift.title) #\(gift.number)", font: titleFont, textColor: primaryTextColor)
Expand All @@ -1113,7 +1113,7 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
let attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: peerIds)
attributedString = addAttributesToStringWithRanges(strings.Notification_StarsGift_Upgrade(peerName)._tuple, body: bodyAttributes, argumentAttributes: attributes)
}
} else if isTransferred {
} else {
if message.author?.id == accountPeerId {
attributedString = NSAttributedString(string: strings.Notification_StarsGift_TransferYou, font: titleFont, textColor: primaryTextColor)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ public final class ButtonComponent: Component {
} else {
shimmeringTransition = .immediate
shimmeringView = ButtonShimmeringView(frame: .zero)
self.shimmeringView = shimmeringView
self.insertSubview(shimmeringView, at: 0)
}
shimmeringView.update(size: availableSize, background: component.background, cornerRadius: component.background.cornerRadius, transition: shimmeringTransition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public class ChatMessageGiftBubbleContentNode: ChatMessageBubbleContentNode {
buttonTitle = item.presentationData.strings.Notification_PremiumPrize_View
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 {
isStarGift = true
let authorName = item.message.author.flatMap { EnginePeer($0) }?.compactDisplayTitle ?? ""
Expand All @@ -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
} else if upgradeStars != nil {
text = item.presentationData.strings.Notification_StarGift_Subtitle_Upgrade
} else if isSelfGift {
} else if isSelfGift && canUpgrade {
text = item.presentationData.strings.Notification_StarsGift_Subtitle_Self
} else if savedToProfile {
if let convertStars {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ final class GiftOptionsScreenComponent: Component {
let bottomContentInset: CGFloat = 24.0
let sideInset: CGFloat = 16.0 + environment.safeInsets.left
let sectionSpacing: CGFloat = 24.0
let headerSideInset: CGFloat = 24.0 + environment.safeInsets.left

let _ = bottomContentInset
let _ = sectionSpacing
Expand Down Expand Up @@ -620,7 +621,7 @@ final class GiftOptionsScreenComponent: Component {
horizontalAlignment: .center
)),
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 premiumTitleView.superview == nil {
Expand Down Expand Up @@ -676,7 +677,7 @@ final class GiftOptionsScreenComponent: Component {
}
)),
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)
if let premiumDescriptionView = self.premiumDescription.view {
Expand Down Expand Up @@ -818,7 +819,7 @@ final class GiftOptionsScreenComponent: Component {
horizontalAlignment: .center
)),
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 starsTitleView.superview == nil {
Expand Down Expand Up @@ -864,7 +865,7 @@ final class GiftOptionsScreenComponent: Component {
}
)),
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)
if let starsDescriptionView = self.starsDescription.view {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
context: AccountContext,
subject: GiftViewScreen.Subject,
forceDark: Bool = false,
updateSavedToProfile: ((Bool) -> Void)? = nil,
updateSavedToProfile: ((EngineMessage.Id, Bool) -> Void)? = nil,
convertToStars: (() -> Void)? = nil,
transferGift: ((Bool, EnginePeer.Id) -> Void)? = nil,
upgradeGift: ((Int64?, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)? = nil
Expand Down Expand Up @@ -1890,7 +1890,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
}

if let updateSavedToProfile {
updateSavedToProfile(added)
updateSavedToProfile(messageId, added)
} else {
let _ = (context.engine.payments.updateStarGiftAddedToProfile(messageId: messageId, added: added)
|> deliverOnMainQueue).startStandalone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {})
}
}))
} 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) {
items[currentPeerInfoSection]!.append(PeerInfoScreenActionItem(id: 7, text: presentationData.strings.Bot_AddToChat, color: .accent, action: {
interaction.openAddBotToGroup()
Expand Down Expand Up @@ -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: {})
}
}))
} 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr
let controller = GiftViewScreen(
context: self.context,
subject: .profileGift(self.peerId, product),
updateSavedToProfile: { [weak self] added in
guard let self, let messageId = product.messageId else {
updateSavedToProfile: { [weak self] messageId, added in
guard let self else {
return
}
self.profileGifts.updateStarGiftAddedToProfile(messageId: messageId, added: added)
Expand Down

0 comments on commit 3bbb677

Please sign in to comment.