Skip to content

Commit 4c0dc35

Browse files
author
Isaac
committed
Merge commit 'bc4b8152c35f20944679b4e86be22054b6c87b97'
2 parents 23ebf39 + bc4b815 commit 4c0dc35

File tree

14 files changed

+255
-56
lines changed

14 files changed

+255
-56
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13896,6 +13896,7 @@ Sorry for the inconvenience.";
1389613896
"Chat.NonContactUser.UpdatedDays_any" = "%@ days ago";
1389713897

1389813898
"Chat.InputTextPaidMessagePlaceholder" = "Message for %@";
13899+
"Chat.InputTextPaidCommentPlaceholder" = "Comment for %@";
1389913900

1390013901
"Privacy.Messages.Stars_1" = "%@ Star";
1390113902
"Privacy.Messages.Stars_any" = "%@ Stars";
@@ -13943,6 +13944,7 @@ Sorry for the inconvenience.";
1394313944
"Chat.PaidMessage.Confirm.PayForMessage_1" = "Pay for %@ Message";
1394413945
"Chat.PaidMessage.Confirm.PayForMessage_any" = "Pay for %@ Messages";
1394513946
"Chat.PaidMessage.Confirm.Single.Text" = "**%1$@** charges **%2$@** per incoming message. Would you like to pay **%3$@** to send %4$@?";
13947+
"Chat.PaidMessage.Confirm.SingleComment.Text" = "**%1$@** charges **%2$@** per comment. Would you like to pay **%3$@** to send %4$@?";
1394613948
"Chat.PaidMessage.Confirm.Multiple.Text" = "You selected %1$@ who charge Stars for messages. Would you like to pay **%2$@** Stars to send %3$@?";
1394713949
"Chat.PaidMessage.Confirm.Text.Users_1" = "**%@** user";
1394813950
"Chat.PaidMessage.Confirm.Text.Users_any" = "**%@** users";

submodules/TelegramApi/Sources/Api0.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
936936
dict[779004698] = { return Api.StarsSubscription.parse_starsSubscription($0) }
937937
dict[88173912] = { return Api.StarsSubscriptionPricing.parse_starsSubscriptionPricing($0) }
938938
dict[198776256] = { return Api.StarsTopupOption.parse_starsTopupOption($0) }
939-
dict[-321582812] = { return Api.StarsTransaction.parse_starsTransaction($0) }
939+
dict[-1549805238] = { return Api.StarsTransaction.parse_starsTransaction($0) }
940940
dict[-670195363] = { return Api.StarsTransactionPeer.parse_starsTransactionPeer($0) }
941941
dict[-110658899] = { return Api.StarsTransactionPeer.parse_starsTransactionPeerAPI($0) }
942942
dict[1617438738] = { return Api.StarsTransactionPeer.parse_starsTransactionPeerAds($0) }

submodules/TelegramApi/Sources/Api25.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,13 @@ public extension Api {
334334
}
335335
public extension Api {
336336
enum StarsTransaction: TypeConstructorDescription {
337-
case starsTransaction(flags: Int32, id: String, stars: Api.StarsAmount, date: Int32, peer: Api.StarsTransactionPeer, title: String?, description: String?, photo: Api.WebDocument?, transactionDate: Int32?, transactionUrl: String?, botPayload: Buffer?, msgId: Int32?, extendedMedia: [Api.MessageMedia]?, subscriptionPeriod: Int32?, giveawayPostId: Int32?, stargift: Api.StarGift?, floodskipNumber: Int32?, starrefCommissionPermille: Int32?, starrefPeer: Api.Peer?, starrefAmount: Api.StarsAmount?, paidMessages: Int32?)
337+
case starsTransaction(flags: Int32, id: String, stars: Api.StarsAmount, date: Int32, peer: Api.StarsTransactionPeer, title: String?, description: String?, photo: Api.WebDocument?, transactionDate: Int32?, transactionUrl: String?, botPayload: Buffer?, msgId: Int32?, extendedMedia: [Api.MessageMedia]?, subscriptionPeriod: Int32?, giveawayPostId: Int32?, stargift: Api.StarGift?, floodskipNumber: Int32?, starrefCommissionPermille: Int32?, starrefPeer: Api.Peer?, starrefAmount: Api.StarsAmount?, paidMessages: Int32?, premiumGiftMonths: Int32?)
338338

339339
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
340340
switch self {
341-
case .starsTransaction(let flags, let id, let stars, let date, let peer, let title, let description, let photo, let transactionDate, let transactionUrl, let botPayload, let msgId, let extendedMedia, let subscriptionPeriod, let giveawayPostId, let stargift, let floodskipNumber, let starrefCommissionPermille, let starrefPeer, let starrefAmount, let paidMessages):
341+
case .starsTransaction(let flags, let id, let stars, let date, let peer, let title, let description, let photo, let transactionDate, let transactionUrl, let botPayload, let msgId, let extendedMedia, let subscriptionPeriod, let giveawayPostId, let stargift, let floodskipNumber, let starrefCommissionPermille, let starrefPeer, let starrefAmount, let paidMessages, let premiumGiftMonths):
342342
if boxed {
343-
buffer.appendInt32(-321582812)
343+
buffer.appendInt32(-1549805238)
344344
}
345345
serializeInt32(flags, buffer: buffer, boxed: false)
346346
serializeString(id, buffer: buffer, boxed: false)
@@ -367,14 +367,15 @@ public extension Api {
367367
if Int(flags) & Int(1 << 17) != 0 {starrefPeer!.serialize(buffer, true)}
368368
if Int(flags) & Int(1 << 17) != 0 {starrefAmount!.serialize(buffer, true)}
369369
if Int(flags) & Int(1 << 19) != 0 {serializeInt32(paidMessages!, buffer: buffer, boxed: false)}
370+
if Int(flags) & Int(1 << 20) != 0 {serializeInt32(premiumGiftMonths!, buffer: buffer, boxed: false)}
370371
break
371372
}
372373
}
373374

374375
public func descriptionFields() -> (String, [(String, Any)]) {
375376
switch self {
376-
case .starsTransaction(let flags, let id, let stars, let date, let peer, let title, let description, let photo, let transactionDate, let transactionUrl, let botPayload, let msgId, let extendedMedia, let subscriptionPeriod, let giveawayPostId, let stargift, let floodskipNumber, let starrefCommissionPermille, let starrefPeer, let starrefAmount, let paidMessages):
377-
return ("starsTransaction", [("flags", flags as Any), ("id", id as Any), ("stars", stars as Any), ("date", date as Any), ("peer", peer as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("transactionDate", transactionDate as Any), ("transactionUrl", transactionUrl as Any), ("botPayload", botPayload as Any), ("msgId", msgId as Any), ("extendedMedia", extendedMedia as Any), ("subscriptionPeriod", subscriptionPeriod as Any), ("giveawayPostId", giveawayPostId as Any), ("stargift", stargift as Any), ("floodskipNumber", floodskipNumber as Any), ("starrefCommissionPermille", starrefCommissionPermille as Any), ("starrefPeer", starrefPeer as Any), ("starrefAmount", starrefAmount as Any), ("paidMessages", paidMessages as Any)])
377+
case .starsTransaction(let flags, let id, let stars, let date, let peer, let title, let description, let photo, let transactionDate, let transactionUrl, let botPayload, let msgId, let extendedMedia, let subscriptionPeriod, let giveawayPostId, let stargift, let floodskipNumber, let starrefCommissionPermille, let starrefPeer, let starrefAmount, let paidMessages, let premiumGiftMonths):
378+
return ("starsTransaction", [("flags", flags as Any), ("id", id as Any), ("stars", stars as Any), ("date", date as Any), ("peer", peer as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("transactionDate", transactionDate as Any), ("transactionUrl", transactionUrl as Any), ("botPayload", botPayload as Any), ("msgId", msgId as Any), ("extendedMedia", extendedMedia as Any), ("subscriptionPeriod", subscriptionPeriod as Any), ("giveawayPostId", giveawayPostId as Any), ("stargift", stargift as Any), ("floodskipNumber", floodskipNumber as Any), ("starrefCommissionPermille", starrefCommissionPermille as Any), ("starrefPeer", starrefPeer as Any), ("starrefAmount", starrefAmount as Any), ("paidMessages", paidMessages as Any), ("premiumGiftMonths", premiumGiftMonths as Any)])
378379
}
379380
}
380381

@@ -435,6 +436,8 @@ public extension Api {
435436
} }
436437
var _21: Int32?
437438
if Int(_1!) & Int(1 << 19) != 0 {_21 = reader.readInt32() }
439+
var _22: Int32?
440+
if Int(_1!) & Int(1 << 20) != 0 {_22 = reader.readInt32() }
438441
let _c1 = _1 != nil
439442
let _c2 = _2 != nil
440443
let _c3 = _3 != nil
@@ -456,8 +459,9 @@ public extension Api {
456459
let _c19 = (Int(_1!) & Int(1 << 17) == 0) || _19 != nil
457460
let _c20 = (Int(_1!) & Int(1 << 17) == 0) || _20 != nil
458461
let _c21 = (Int(_1!) & Int(1 << 19) == 0) || _21 != nil
459-
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 {
460-
return Api.StarsTransaction.starsTransaction(flags: _1!, id: _2!, stars: _3!, date: _4!, peer: _5!, title: _6, description: _7, photo: _8, transactionDate: _9, transactionUrl: _10, botPayload: _11, msgId: _12, extendedMedia: _13, subscriptionPeriod: _14, giveawayPostId: _15, stargift: _16, floodskipNumber: _17, starrefCommissionPermille: _18, starrefPeer: _19, starrefAmount: _20, paidMessages: _21)
462+
let _c22 = (Int(_1!) & Int(1 << 20) == 0) || _22 != nil
463+
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 && _c22 {
464+
return Api.StarsTransaction.starsTransaction(flags: _1!, id: _2!, stars: _3!, date: _4!, peer: _5!, title: _6, description: _7, photo: _8, transactionDate: _9, transactionUrl: _10, botPayload: _11, msgId: _12, extendedMedia: _13, subscriptionPeriod: _14, giveawayPostId: _15, stargift: _16, floodskipNumber: _17, starrefCommissionPermille: _18, starrefPeer: _19, starrefAmount: _20, paidMessages: _21, premiumGiftMonths: _22)
461465
}
462466
else {
463467
return nil

submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ private final class StarsContextImpl {
551551
}
552552
var transactions = state.transactions
553553
if addTransaction {
554-
transactions.insert(.init(flags: [.isLocal], id: "\(arc4random())", count: balance, date: Int32(Date().timeIntervalSince1970), peer: .appStore, title: nil, description: nil, photo: nil, transactionDate: nil, transactionUrl: nil, paidMessageId: nil, giveawayMessageId: nil, media: [], subscriptionPeriod: nil, starGift: nil, floodskipNumber: nil, starrefCommissionPermille: nil, starrefPeerId: nil, starrefAmount: nil, paidMessageCount: nil), at: 0)
554+
transactions.insert(.init(flags: [.isLocal], id: "\(arc4random())", count: balance, date: Int32(Date().timeIntervalSince1970), peer: .appStore, title: nil, description: nil, photo: nil, transactionDate: nil, transactionUrl: nil, paidMessageId: nil, giveawayMessageId: nil, media: [], subscriptionPeriod: nil, starGift: nil, floodskipNumber: nil, starrefCommissionPermille: nil, starrefPeerId: nil, starrefAmount: nil, paidMessageCount: nil, premiumGiftMonths: nil), at: 0)
555555
}
556556

557557
self.updateState(StarsContext.State(flags: [.isPendingBalance], balance: max(StarsAmount(value: 0, nanos: 0), state.balance + balance), subscriptions: state.subscriptions, canLoadMoreSubscriptions: state.canLoadMoreSubscriptions, transactions: transactions, canLoadMoreTransactions: state.canLoadMoreTransactions, isLoading: state.isLoading))
@@ -573,7 +573,7 @@ private final class StarsContextImpl {
573573
private extension StarsContext.State.Transaction {
574574
init?(apiTransaction: Api.StarsTransaction, peerId: EnginePeer.Id?, transaction: Transaction) {
575575
switch apiTransaction {
576-
case let .starsTransaction(apiFlags, id, stars, date, transactionPeer, title, description, photo, transactionDate, transactionUrl, _, messageId, extendedMedia, subscriptionPeriod, giveawayPostId, starGift, floodskipNumber, starrefCommissionPermille, starrefPeer, starrefAmount, paidMessageCount):
576+
case let .starsTransaction(apiFlags, id, stars, date, transactionPeer, title, description, photo, transactionDate, transactionUrl, _, messageId, extendedMedia, subscriptionPeriod, giveawayPostId, starGift, floodskipNumber, starrefCommissionPermille, starrefPeer, starrefAmount, paidMessageCount, premiumGiftMonths):
577577
let parsedPeer: StarsContext.State.Transaction.Peer
578578
var paidMessageId: MessageId?
579579
var giveawayMessageId: MessageId?
@@ -636,7 +636,7 @@ private extension StarsContext.State.Transaction {
636636
let media = extendedMedia.flatMap({ $0.compactMap { textMediaAndExpirationTimerFromApiMedia($0, PeerId(0)).media } }) ?? []
637637
let _ = subscriptionPeriod
638638

639-
self.init(flags: flags, id: id, count: StarsAmount(apiAmount: stars), date: date, peer: parsedPeer, title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), transactionDate: transactionDate, transactionUrl: transactionUrl, paidMessageId: paidMessageId, giveawayMessageId: giveawayMessageId, media: media, subscriptionPeriod: subscriptionPeriod, starGift: starGift.flatMap { StarGift(apiStarGift: $0) }, floodskipNumber: floodskipNumber, starrefCommissionPermille: starrefCommissionPermille, starrefPeerId: starrefPeer?.peerId, starrefAmount: starrefAmount.flatMap(StarsAmount.init(apiAmount:)), paidMessageCount: paidMessageCount)
639+
self.init(flags: flags, id: id, count: StarsAmount(apiAmount: stars), date: date, peer: parsedPeer, title: title, description: description, photo: photo.flatMap(TelegramMediaWebFile.init), transactionDate: transactionDate, transactionUrl: transactionUrl, paidMessageId: paidMessageId, giveawayMessageId: giveawayMessageId, media: media, subscriptionPeriod: subscriptionPeriod, starGift: starGift.flatMap { StarGift(apiStarGift: $0) }, floodskipNumber: floodskipNumber, starrefCommissionPermille: starrefCommissionPermille, starrefPeerId: starrefPeer?.peerId, starrefAmount: starrefAmount.flatMap(StarsAmount.init(apiAmount:)), paidMessageCount: paidMessageCount, premiumGiftMonths: premiumGiftMonths)
640640
}
641641
}
642642
}
@@ -717,6 +717,7 @@ public final class StarsContext {
717717
public let starrefPeerId: PeerId?
718718
public let starrefAmount: StarsAmount?
719719
public let paidMessageCount: Int32?
720+
public let premiumGiftMonths: Int32?
720721

721722
public init(
722723
flags: Flags,
@@ -738,7 +739,8 @@ public final class StarsContext {
738739
starrefCommissionPermille: Int32?,
739740
starrefPeerId: PeerId?,
740741
starrefAmount: StarsAmount?,
741-
paidMessageCount: Int32?
742+
paidMessageCount: Int32?,
743+
premiumGiftMonths: Int32?
742744
) {
743745
self.flags = flags
744746
self.id = id
@@ -760,6 +762,7 @@ public final class StarsContext {
760762
self.starrefPeerId = starrefPeerId
761763
self.starrefAmount = starrefAmount
762764
self.paidMessageCount = paidMessageCount
765+
self.premiumGiftMonths = premiumGiftMonths
763766
}
764767

765768
public static func == (lhs: Transaction, rhs: Transaction) -> Bool {
@@ -823,6 +826,9 @@ public final class StarsContext {
823826
if lhs.paidMessageCount != rhs.paidMessageCount {
824827
return false
825828
}
829+
if lhs.premiumGiftMonths != rhs.premiumGiftMonths {
830+
return false
831+
}
826832
return true
827833
}
828834
}

submodules/TelegramUI/Components/Chat/ChatEmptyNode/Sources/ChatEmptyNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ public final class ChatEmptyNodePremiumRequiredChatContent: ASDisplayNode, ChatE
12681268
public func updateLayout(interfaceState: ChatPresentationInterfaceState, subject: ChatEmptyNode.Subject, size: CGSize, transition: ContainedViewLayoutTransition) -> CGSize {
12691269
let serviceColor = serviceMessageColorComponents(theme: interfaceState.theme, wallpaper: interfaceState.chatWallpaper)
12701270

1271-
let maxWidth = min(200.0, size.width)
1271+
let maxWidth = min(270.0, size.width)
12721272

12731273
let sideInset: CGFloat = 22.0
12741274
let topInset: CGFloat = 16.0

submodules/TelegramUI/Components/Chat/ChatMessagePaymentAlertController/Sources/ChatMessagePaymentAlertController.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,11 @@ public func chatMessagePaymentAlertController(
439439
if peers.count == 1, let peer = peers.first {
440440
let amountString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Stars(Int32(amount.value))
441441
let totalString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Stars(Int32(amount.value * Int64(count)))
442-
text = presentationData.strings.Chat_PaidMessage_Confirm_Single_Text(peer.compactDisplayTitle, amountString, totalString, messagesString).string
442+
if case let .channel(channel) = peer, case .broadcast = channel.info {
443+
text = presentationData.strings.Chat_PaidMessage_Confirm_SingleComment_Text(peer.compactDisplayTitle, amountString, totalString, messagesString).string
444+
} else {
445+
text = presentationData.strings.Chat_PaidMessage_Confirm_Single_Text(peer.compactDisplayTitle, amountString, totalString, messagesString).string
446+
}
443447
} else {
444448
let amount = totalAmount ?? amount
445449
let usersString = presentationData.strings.Chat_PaidMessage_Confirm_Text_Users(Int32(peers.count))

submodules/TelegramUI/Components/Chat/ChatUserInfoItem/Sources/ChatUserInfoItem.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public final class ChatUserInfoItem: ListViewItem {
9292
}
9393
}
9494

95-
public final class ChatUserInfoItemNode: ListViewItemNode {
95+
public final class ChatUserInfoItemNode: ListViewItemNode, ASGestureRecognizerDelegate {
9696
public var controllerInteraction: ChatControllerInteraction?
9797

9898
public let offsetContainer: ASDisplayNode
@@ -210,6 +210,29 @@ public final class ChatUserInfoItemNode: ListViewItemNode {
210210
self.groupsButtonNode.addTarget(self, action: #selector(self.groupsPressed), forControlEvents: .touchUpInside)
211211
}
212212

213+
override public func didLoad() {
214+
super.didLoad()
215+
216+
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))
217+
tapRecognizer.delegate = self.wrappedGestureRecognizerDelegate
218+
self.offsetContainer.view.addGestureRecognizer(tapRecognizer)
219+
}
220+
221+
public override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
222+
let location = gestureRecognizer.location(in: self.offsetContainer.view)
223+
if let backgroundContent = self.backgroundContent, backgroundContent.frame.contains(location) {
224+
return true
225+
}
226+
return false
227+
}
228+
229+
@objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) {
230+
guard let item = self.item else {
231+
return
232+
}
233+
item.controllerInteraction.openPeer(item.peer, .info(nil), nil, .default)
234+
}
235+
213236
override public func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) {
214237
super.updateAbsoluteRect(rect, within: containerSize)
215238

submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
47034703
return
47044704
}
47054705
let sourceRect = sourceView.convert(sourceView.bounds, to: controller.view)
4706+
guard sourceRect.minY > 44.0 else {
4707+
return
4708+
}
47064709

47074710
let backgroundColor: UIColor
47084711
if !self.headerNode.isAvatarExpanded, let contentButtonBackgroundColor = self.headerNode.contentButtonBackgroundColor {

0 commit comments

Comments
 (0)