From fa463380103f6cb3254242a8fce4cfbc0ec4cca4 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sat, 3 May 2025 17:07:17 +0400 Subject: [PATCH] Various fixes --- .../TelegramEngine/Payments/StarGifts.swift | 23 +------ .../Sources/GiftViewScreen.swift | 64 ++++++++++--------- 2 files changed, 38 insertions(+), 49 deletions(-) diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift index 6b44951fc8..7b5a1c63b5 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift @@ -1542,24 +1542,7 @@ private final class ProfileGiftsContextImpl { return EmptyDisposable } - var saveToProfile = false - if let gift = self.gifts.first(where: { $0.reference == reference }) { - if !gift.savedToProfile { - saveToProfile = true - } - } else if let gift = self.filteredGifts.first(where: { $0.reference == reference }) { - if !gift.savedToProfile { - saveToProfile = true - } - } - - var signal = _internal_updateStarGiftResalePrice(account: self.account, reference: reference, price: price) - if saveToProfile { - signal = _internal_updateStarGiftAddedToProfile(account: self.account, reference: reference, added: true) - |> castError(UpdateStarGiftPriceError.self) - |> then(signal) - } - + let signal = _internal_updateStarGiftResalePrice(account: self.account, reference: reference, price: price) let disposable = MetaDisposable() disposable.set( (signal @@ -1584,7 +1567,7 @@ private final class ProfileGiftsContextImpl { }) { if case let .unique(uniqueGift) = self.gifts[index].gift { let updatedUniqueGift = uniqueGift.withResellStars(price) - let updatedGift = self.gifts[index].withGift(.unique(updatedUniqueGift)).withSavedToProfile(true) + let updatedGift = self.gifts[index].withGift(.unique(updatedUniqueGift)) self.gifts[index] = updatedGift } } @@ -1607,7 +1590,7 @@ private final class ProfileGiftsContextImpl { }) { if case let .unique(uniqueGift) = self.filteredGifts[index].gift { let updatedUniqueGift = uniqueGift.withResellStars(price) - let updatedGift = self.filteredGifts[index].withGift(.unique(updatedUniqueGift)).withSavedToProfile(true) + let updatedGift = self.filteredGifts[index].withGift(.unique(updatedUniqueGift)) self.filteredGifts[index] = updatedGift } } diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index db684ec86e..ff8d1fb812 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -306,40 +306,46 @@ private final class GiftViewSheetContent: CombinedComponent { controller.dismissAllTooltips() - if gifts { - if let profileController = self.context.sharedContext.makePeerInfoController( - context: self.context, - updatedPresentationData: nil, - peer: peer._asPeer(), - mode: peer.id == self.context.account.peerId ? .myProfileGifts : .gifts, - avatarInitiallyExpanded: false, - fromChat: false, - requestsContext: nil - ) { - controller.push(profileController) + let context = self.context + let action = { + if gifts { + if let profileController = context.sharedContext.makePeerInfoController( + context: context, + updatedPresentationData: nil, + peer: peer._asPeer(), + mode: peer.id == context.account.peerId ? .myProfileGifts : .gifts, + avatarInitiallyExpanded: false, + fromChat: false, + requestsContext: nil + ) { + navigationController.pushViewController(profileController) + } + } else { + context.sharedContext.navigateToChatController(NavigateToChatControllerParams( + navigationController: navigationController, + chatController: nil, + context: context, + chatLocation: .peer(peer), + subject: nil, + botStart: nil, + updateTextInputState: nil, + keepStack: .always, + useExisting: true, + purposefulAction: nil, + scrollToEndIfExists: false, + activateMessageSearch: nil, + animated: true + )) } - } else { - self.context.sharedContext.navigateToChatController(NavigateToChatControllerParams( - navigationController: navigationController, - chatController: nil, - context: self.context, - chatLocation: .peer(peer), - subject: nil, - botStart: nil, - updateTextInputState: nil, - keepStack: .always, - useExisting: true, - purposefulAction: nil, - scrollToEndIfExists: false, - activateMessageSearch: nil, - animated: true - )) } if dismiss { - Queue.mainQueue().after(0.6, { - self.dismiss(animated: false) + self.dismiss(animated: true) + Queue.mainQueue().after(0.4, { + action() }) + } else { + action() } }