diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 0b3c86d41f..bd1dc5bfab 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -13961,6 +13961,8 @@ Sorry for the inconvenience."; "PeerInfo.Gifts.ToastUnpinned.Text" = "Gift Unpinned."; "PeerInfo.Gifts.ToastPinned.Title" = "Gift Pinned"; "PeerInfo.Gifts.ToastPinned.Text" = "Now it will always be shown on the top."; +"PeerInfo.Gifts.ToastPinned.TitleNew" = "%@ Pinned"; +"PeerInfo.Gifts.ToastPinned.ReplacingText" = "replacing %@."; "Chat.PaidMessage.Confirm.Title" = "Confirm Payment"; "Chat.PaidMessage.Confirm.DontAskAgain" = "Don't ask again"; diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift index efe9ecc5e0..9a2f561768 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift @@ -514,6 +514,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } } } else { + var dismissImpl: (() -> Void)? let controller = GiftViewScreen( context: self.context, subject: .profileGift(self.peerId, product), @@ -550,11 +551,36 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr let controller = GiftUnpinScreen( context: context, gifts: gifts, - completion: { [weak self] reference in + completion: { [weak self] unpinnedReference in guard let self else { return } - self.profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: false) + dismissImpl?() + + var replacingTitle = "" + for gift in gifts { + if gift.reference == unpinnedReference, case let .unique(uniqueGift) = gift.gift { + replacingTitle = "\(uniqueGift.title) #\(presentationStringsFormattedNumber(uniqueGift.number, params.presentationData.dateTimeFormat.groupingSeparator))" + } + } + + var updatedPinnedGifts = self.pinnedReferences + if let index = updatedPinnedGifts.firstIndex(of: unpinnedReference), let reference = product.reference { + updatedPinnedGifts[index] = reference + } + self.profileGifts.updatePinnedToTopStarGifts(references: updatedPinnedGifts) + + var title = "" + if case let .unique(uniqueGift) = product.gift { + title = "\(uniqueGift.title) #\(presentationStringsFormattedNumber(uniqueGift.number, params.presentationData.dateTimeFormat.groupingSeparator))" + } + + let _ = self.scrollToTop() + Queue.mainQueue().after(0.35) { + let toastTitle = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_TitleNew(title).string + let toastText = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_ReplacingText(replacingTitle).string + 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)) + } } ) self.parentController?.push(controller) @@ -564,10 +590,15 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr if let reference = product.reference { self.profileGifts.updateStarGiftPinnedToTop(reference: reference, pinnedToTop: pinnedToTop) + var title = "" + if case let .unique(uniqueGift) = product.gift { + title = "\(uniqueGift.title) #\(presentationStringsFormattedNumber(uniqueGift.number, params.presentationData.dateTimeFormat.groupingSeparator))" + } + if pinnedToTop { let _ = self.scrollToTop() Queue.mainQueue().after(0.35) { - let toastTitle = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_Title + let toastTitle = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_TitleNew(title).string let toastText = params.presentationData.strings.PeerInfo_Gifts_ToastPinned_Text 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)) } @@ -585,6 +616,9 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr } } ) + dismissImpl = { [weak controller] in + controller?.dismissAnimated() + } self.parentController?.push(controller) } }, @@ -1041,7 +1075,11 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr toastTitle = nil toastText = strings.PeerInfo_Gifts_ToastUnpinned_Text } else { - toastTitle = strings.PeerInfo_Gifts_ToastPinned_Title + var title = "" + if case let .unique(uniqueGift) = gift.gift { + title = "\(uniqueGift.title) #\(presentationStringsFormattedNumber(uniqueGift.number, presentationData.dateTimeFormat.groupingSeparator))" + } + toastTitle = strings.PeerInfo_Gifts_ToastPinned_TitleNew(title).string toastText = strings.PeerInfo_Gifts_ToastPinned_Text } self.parentController?.present(UndoOverlayController(presentationData: presentationData, content: .universal(animation: !pinnedToTop ? "anim_toastunpin" : "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)) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 15de45a0dc..b6aac3cb2b 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -6397,7 +6397,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if case let .known(value) = cachedData.businessIntro { businessIntro = value } - alwaysShowGiftButton = cachedData.flags.contains(.displayGiftButton) + if cachedData.disallowedGifts != .All { + alwaysShowGiftButton = cachedData.flags.contains(.displayGiftButton) + } } else if let cachedData = peerView.cachedData as? CachedGroupData { var invitedBy: Peer? if let invitedByPeerId = cachedData.invitedBy {