Skip to content

Commit 975430a

Browse files
committed
Various fixes
1 parent 9e099d6 commit 975430a

File tree

3 files changed

+37
-39
lines changed

3 files changed

+37
-39
lines changed

submodules/TelegramUI/Components/Gifts/GiftStoreScreen/Sources/GiftStoreScreen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ final class GiftStoreScreenComponent: Component {
277277
buyGift: { slug, peerId, price in
278278
return self.state?.starGiftsContext.buyStarGift(slug: slug, peerId: peerId, price: price) ?? .complete()
279279
},
280-
updateResellStars: { price in
280+
updateResellStars: { _, price in
281281
return self.state?.starGiftsContext.updateStarGiftResellPrice(slug: uniqueGift.slug, price: price) ?? .complete()
282282
}
283283
)

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private final class GiftViewSheetContent: CombinedComponent {
154154
super.init()
155155

156156
if let arguments = subject.arguments {
157-
if let upgradeStars = arguments.upgradeStars, upgradeStars > 0, !arguments.nameHidden {
157+
if let upgradeStars = arguments.upgradeStars, upgradeStars > 0, !arguments.nameHidden && !arguments.upgradeSeparate {
158158
self.keepOriginalInfo = true
159159
}
160160

@@ -981,7 +981,7 @@ private final class GiftViewSheetContent: CombinedComponent {
981981
guard let self, let controller else {
982982
return
983983
}
984-
let _ = ((controller.updateResellStars?(nil) ?? context.engine.payments.updateStarGiftResalePrice(reference: reference, price: nil))
984+
let _ = ((controller.updateResellStars?(reference, nil) ?? context.engine.payments.updateStarGiftResalePrice(reference: reference, price: nil))
985985
|> deliverOnMainQueue).startStandalone(error: { error in
986986

987987
}, completed: { [weak self, weak controller] in
@@ -1031,7 +1031,7 @@ private final class GiftViewSheetContent: CombinedComponent {
10311031
return
10321032
}
10331033

1034-
let _ = ((controller.updateResellStars?(price) ?? context.engine.payments.updateStarGiftResalePrice(reference: reference, price: price))
1034+
let _ = ((controller.updateResellStars?(reference, price) ?? context.engine.payments.updateStarGiftResalePrice(reference: reference, price: price))
10351035
|> deliverOnMainQueue).startStandalone(error: { [weak self, weak controller] error in
10361036
guard let self else {
10371037
return
@@ -1160,15 +1160,15 @@ private final class GiftViewSheetContent: CombinedComponent {
11601160
var items: [ContextMenuItem] = []
11611161
let strings = presentationData.strings
11621162

1163-
if let _ = arguments.reference, case .unique = arguments.gift, let togglePinnedToTop = controller.togglePinnedToTop, let pinnedToTop = arguments.pinnedToTop {
1163+
if let reference = arguments.reference, case .unique = arguments.gift, let togglePinnedToTop = controller.togglePinnedToTop, let pinnedToTop = arguments.pinnedToTop {
11641164
items.append(.action(ContextMenuActionItem(text: pinnedToTop ? strings.PeerInfo_Gifts_Context_Unpin : strings.PeerInfo_Gifts_Context_Pin , icon: { theme in generateTintedImage(image: UIImage(bundleImageName: pinnedToTop ? "Chat/Context Menu/Unpin" : "Chat/Context Menu/Pin"), color: theme.contextMenu.primaryColor) }, action: { [weak self] c, f in
11651165
c?.dismiss(completion: { [weak self, weak controller] in
11661166
guard let self, let controller else {
11671167
return
11681168
}
11691169

11701170
let pinnedToTop = !pinnedToTop
1171-
if togglePinnedToTop(pinnedToTop) {
1171+
if togglePinnedToTop(reference, pinnedToTop) {
11721172
if pinnedToTop {
11731173
controller.dismissAnimated()
11741174
} else {
@@ -4457,12 +4457,12 @@ public class GiftViewScreen: ViewControllerComponentContainer {
44574457
case upgradePreview([StarGift.UniqueGift.Attribute], String)
44584458
case wearPreview(StarGift.UniqueGift)
44594459

4460-
var arguments: (peerId: EnginePeer.Id?, fromPeerId: EnginePeer.Id?, fromPeerName: String?, messageId: EngineMessage.Id?, reference: StarGiftReference?, incoming: Bool, gift: StarGift, date: Int32, convertStars: Int64?, text: String?, entities: [MessageTextEntity]?, nameHidden: Bool, savedToProfile: Bool, pinnedToTop: Bool?, converted: Bool, upgraded: Bool, refunded: Bool, canUpgrade: Bool, upgradeStars: Int64?, transferStars: Int64?, resellAmounts: [CurrencyAmount]?, canExportDate: Int32?, upgradeMessageId: Int32?, canTransferDate: Int32?, canResaleDate: Int32?, prepaidUpgradeHash: String?)? {
4460+
var arguments: (peerId: EnginePeer.Id?, fromPeerId: EnginePeer.Id?, fromPeerName: String?, messageId: EngineMessage.Id?, reference: StarGiftReference?, incoming: Bool, gift: StarGift, date: Int32, convertStars: Int64?, text: String?, entities: [MessageTextEntity]?, nameHidden: Bool, savedToProfile: Bool, pinnedToTop: Bool?, converted: Bool, upgraded: Bool, refunded: Bool, canUpgrade: Bool, upgradeStars: Int64?, transferStars: Int64?, resellAmounts: [CurrencyAmount]?, canExportDate: Int32?, upgradeMessageId: Int32?, canTransferDate: Int32?, canResaleDate: Int32?, prepaidUpgradeHash: String?, upgradeSeparate: Bool)? {
44614461
switch self {
44624462
case let .message(message):
44634463
if let action = message.media.first(where: { $0 is TelegramMediaAction }) as? TelegramMediaAction {
44644464
switch action.action {
4465-
case let .starGift(gift, convertStars, text, entities, nameHidden, savedToProfile, converted, upgraded, canUpgrade, upgradeStars, isRefunded, _, upgradeMessageId, peerId, senderId, savedId, prepaidUpgradeHash, giftMessageId, _):
4465+
case let .starGift(gift, convertStars, text, entities, nameHidden, savedToProfile, converted, upgraded, canUpgrade, upgradeStars, isRefunded, _, upgradeMessageId, peerId, senderId, savedId, prepaidUpgradeHash, giftMessageId, upgradeSeparate):
44664466
var reference: StarGiftReference
44674467
if let peerId, let giftMessageId {
44684468
reference = .message(messageId: EngineMessage.Id(peerId: peerId, namespace: Namespaces.Message.Cloud, id: giftMessageId))
@@ -4471,7 +4471,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
44714471
} else {
44724472
reference = .message(messageId: message.id)
44734473
}
4474-
return (message.id.peerId, senderId ?? message.author?.id, message.author?.compactDisplayTitle, message.id, reference, message.flags.contains(.Incoming), gift, message.timestamp, convertStars, text, entities, nameHidden, savedToProfile, nil, converted, upgraded, isRefunded, canUpgrade, upgradeStars, nil, nil, nil, upgradeMessageId, nil, nil, prepaidUpgradeHash)
4474+
return (message.id.peerId, senderId ?? message.author?.id, message.author?.compactDisplayTitle, message.id, reference, message.flags.contains(.Incoming), gift, message.timestamp, convertStars, text, entities, nameHidden, savedToProfile, nil, converted, upgraded, isRefunded, canUpgrade, upgradeStars, nil, nil, nil, upgradeMessageId, nil, nil, prepaidUpgradeHash, upgradeSeparate)
44754475
case let .starGiftUnique(gift, isUpgrade, isTransferred, savedToProfile, canExportDate, transferStars, _, _, peerId, senderId, savedId, _, canTransferDate, canResaleDate):
44764476
var reference: StarGiftReference
44774477
if let peerId, let savedId {
@@ -4496,13 +4496,13 @@ public class GiftViewScreen: ViewControllerComponentContainer {
44964496
if case let .unique(uniqueGift) = gift {
44974497
resellAmounts = uniqueGift.resellAmounts
44984498
}
4499-
return (message.id.peerId, senderId ?? message.author?.id, message.author?.compactDisplayTitle, message.id, reference, incoming, gift, message.timestamp, nil, nil, nil, false, savedToProfile, nil, false, false, false, false, nil, transferStars, resellAmounts, canExportDate, nil, canTransferDate, canResaleDate, nil)
4499+
return (message.id.peerId, senderId ?? message.author?.id, message.author?.compactDisplayTitle, message.id, reference, incoming, gift, message.timestamp, nil, nil, nil, false, savedToProfile, nil, false, false, false, false, nil, transferStars, resellAmounts, canExportDate, nil, canTransferDate, canResaleDate, nil, false)
45004500
default:
45014501
return nil
45024502
}
45034503
}
45044504
case let .uniqueGift(gift, _), let .wearPreview(gift):
4505-
return (nil, nil, nil, nil, nil, false, .unique(gift), 0, nil, nil, nil, false, false, nil, false, false, false, false, nil, nil, gift.resellAmounts, nil, nil, nil, nil, nil)
4505+
return (nil, nil, nil, nil, nil, false, .unique(gift), 0, nil, nil, nil, false, false, nil, false, false, false, false, nil, nil, gift.resellAmounts, nil, nil, nil, nil, nil, false)
45064506
case let .profileGift(peerId, gift):
45074507
var messageId: EngineMessage.Id?
45084508
if case let .message(messageIdValue) = gift.reference {
@@ -4512,7 +4512,7 @@ public class GiftViewScreen: ViewControllerComponentContainer {
45124512
if case let .unique(uniqueGift) = gift.gift {
45134513
resellAmounts = uniqueGift.resellAmounts
45144514
}
4515-
return (peerId, gift.fromPeer?.id, gift.fromPeer?.compactDisplayTitle, messageId, gift.reference, false, gift.gift, gift.date, gift.convertStars, gift.text, gift.entities, gift.nameHidden, gift.savedToProfile, gift.pinnedToTop, false, false, false, gift.canUpgrade, gift.upgradeStars, gift.transferStars, resellAmounts, gift.canExportDate, nil, gift.canTransferDate, gift.canResaleDate, gift.prepaidUpgradeHash)
4515+
return (peerId, gift.fromPeer?.id, gift.fromPeer?.compactDisplayTitle, messageId, gift.reference, false, gift.gift, gift.date, gift.convertStars, gift.text, gift.entities, gift.nameHidden, gift.savedToProfile, gift.pinnedToTop, false, false, false, gift.canUpgrade, gift.upgradeStars, gift.transferStars, resellAmounts, gift.canExportDate, nil, gift.canTransferDate, gift.canResaleDate, gift.prepaidUpgradeHash, gift.upgradeSeparate)
45164516
case .soldOutGift:
45174517
return nil
45184518
case .upgradePreview:
@@ -4557,8 +4557,8 @@ public class GiftViewScreen: ViewControllerComponentContainer {
45574557
fileprivate let transferGift: ((Bool, EnginePeer.Id) -> Signal<Never, TransferStarGiftError>)?
45584558
fileprivate let upgradeGift: ((Int64?, StarGiftReference, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)?
45594559
fileprivate let buyGift: ((String, EnginePeer.Id, CurrencyAmount?) -> Signal<Never, BuyStarGiftError>)?
4560-
fileprivate let updateResellStars: ((CurrencyAmount?) -> Signal<Never, UpdateStarGiftPriceError>)?
4561-
fileprivate let togglePinnedToTop: ((Bool) -> Bool)?
4560+
fileprivate let updateResellStars: ((StarGiftReference, CurrencyAmount?) -> Signal<Never, UpdateStarGiftPriceError>)?
4561+
fileprivate let togglePinnedToTop: ((StarGiftReference, Bool) -> Bool)?
45624562
fileprivate let shareStory: ((StarGift.UniqueGift) -> Void)?
45634563
fileprivate let openChatTheme: (() -> Void)?
45644564

@@ -4575,8 +4575,8 @@ public class GiftViewScreen: ViewControllerComponentContainer {
45754575
transferGift: ((Bool, EnginePeer.Id) -> Signal<Never, TransferStarGiftError>)? = nil,
45764576
upgradeGift: ((Int64?, StarGiftReference, Bool) -> Signal<ProfileGiftsContext.State.StarGift, UpgradeStarGiftError>)? = nil,
45774577
buyGift: ((String, EnginePeer.Id, CurrencyAmount?) -> Signal<Never, BuyStarGiftError>)? = nil,
4578-
updateResellStars: ((CurrencyAmount?) -> Signal<Never, UpdateStarGiftPriceError>)? = nil,
4579-
togglePinnedToTop: ((Bool) -> Bool)? = nil,
4578+
updateResellStars: ((StarGiftReference, CurrencyAmount?) -> Signal<Never, UpdateStarGiftPriceError>)? = nil,
4579+
togglePinnedToTop: ((StarGiftReference, Bool) -> Bool)? = nil,
45804580
shareStory: ((StarGift.UniqueGift) -> Void)? = nil,
45814581
openChatTheme: (() -> Void)? = nil
45824582
) {

submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/GiftsListView.swift

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -635,36 +635,34 @@ final class GiftsListView: UIView {
635635
}
636636
return self.profileGifts.buyStarGift(slug: slug, peerId: peerId, price: price)
637637
},
638-
updateResellStars: { [weak self] price in
639-
guard let self, let reference = product.reference else {
638+
updateResellStars: { [weak self] reference, price in
639+
guard let self else {
640640
return .never()
641641
}
642642
return self.profileGifts.updateStarGiftResellPrice(reference: reference, price: price)
643643
},
644-
togglePinnedToTop: { [weak self] pinnedToTop in
644+
togglePinnedToTop: { [weak self] reference, pinnedToTop in
645645
guard let self else {
646646
return false
647647
}
648-
if let reference = product.reference {
649-
if pinnedToTop && self.pinnedReferences.count >= self.maxPinnedCount {
650-
self.displayUnpinScreen?(product, {
651-
dismissImpl?()
652-
})
653-
return false
654-
}
655-
self.profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: pinnedToTop)
656-
657-
var title = ""
658-
if case let .unique(uniqueGift) = product.gift {
659-
title = "\(uniqueGift.title) #\(formatCollectibleNumber(uniqueGift.number, dateTimeFormat: params.presentationData.dateTimeFormat))"
660-
}
661-
662-
if pinnedToTop {
663-
Queue.mainQueue().after(0.35) {
664-
let toastTitle = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_TitleNew(title).string
665-
let toastText = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_Text
666-
self.parentController?.present(UndoOverlayController(presentationData: params.presentationData, content: .universal(animation: "anim_toastpin", scale: 0.06, colors: [:], title: toastTitle, text: toastText, customUndoText: nil, timeout: 5), elevatedLayout: true, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))
667-
}
648+
if pinnedToTop && self.pinnedReferences.count >= self.maxPinnedCount {
649+
self.displayUnpinScreen?(product, {
650+
dismissImpl?()
651+
})
652+
return false
653+
}
654+
self.profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: pinnedToTop)
655+
656+
var title = ""
657+
if case let .unique(uniqueGift) = product.gift {
658+
title = "\(uniqueGift.title) #\(formatCollectibleNumber(uniqueGift.number, dateTimeFormat: params.presentationData.dateTimeFormat))"
659+
}
660+
661+
if pinnedToTop {
662+
Queue.mainQueue().after(0.35) {
663+
let toastTitle = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_TitleNew(title).string
664+
let toastText = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_Text
665+
self.parentController?.present(UndoOverlayController(presentationData: params.presentationData, content: .universal(animation: "anim_toastpin", scale: 0.06, colors: [:], title: toastTitle, text: toastText, customUndoText: nil, timeout: 5), elevatedLayout: true, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))
668666
}
669667
}
670668
return true

0 commit comments

Comments
 (0)