diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 1d47e23299..a90ddeb3da 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -13747,6 +13747,7 @@ Sorry for the inconvenience."; "Gift.SendChannel.Title" = "Gift Preview"; "Gift.SendChannel.HideMyName.Info" = "Hide my name and message from visitors of this channel. The channel admins will still see them."; +"Gift.SendChannel.Upgrade.Info" = "Enable this to let the admins of %@ turn your gift into a unique collectible. [Learn More >]()"; "Media.EditCover" = "Edit Cover"; "Media.ChooseFromGallery" = "Choose From Gallery"; diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 1140625273..dff4dcd6f8 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -590,6 +590,7 @@ public enum PeerInfoControllerMode { case forumTopic(thread: ChatReplyThreadMessage) case recommendedChannels case myProfile + case gifts case myProfileGifts } diff --git a/submodules/Postbox/Sources/ItemCollectionsView.swift b/submodules/Postbox/Sources/ItemCollectionsView.swift index 2566df1e00..1c6c6bfee3 100644 --- a/submodules/Postbox/Sources/ItemCollectionsView.swift +++ b/submodules/Postbox/Sources/ItemCollectionsView.swift @@ -218,24 +218,26 @@ final class MutableItemCollectionsView { } } - let (entries, lower, higher) = aroundEntries(namespaces: namespaces, - aroundIndex: aroundIndex, - count: count, collectionIndexById: { id in - return postbox.itemCollectionInfoTable.getIndex(id: id) - }, - lowerCollectionId: { namespaceList, collectionId, collectionIndex in - return self.lowerCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex) - }, - fetchLowerItems: { collectionId, itemIndex, count in - return self.lowerItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count) - }, - higherCollectionId: { namespaceList, collectionId, collectionIndex in - return self.higherCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex) - }, - fetchHigherItems: { - collectionId, itemIndex, count in - return self.higherItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count) - }) + let (entries, lower, higher) = aroundEntries( + namespaces: namespaces, + aroundIndex: aroundIndex, + count: count, collectionIndexById: { id in + return postbox.itemCollectionInfoTable.getIndex(id: id) + }, + lowerCollectionId: { namespaceList, collectionId, collectionIndex in + return self.lowerCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex) + }, + fetchLowerItems: { collectionId, itemIndex, count in + return self.lowerItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count) + }, + higherCollectionId: { namespaceList, collectionId, collectionIndex in + return self.higherCollectionId(postbox: postbox, namespaceList: namespaceList, collectionId: collectionId, collectionIndex: collectionIndex) + }, + fetchHigherItems: { + collectionId, itemIndex, count in + return self.higherItems(postbox: postbox, collectionId: collectionId, itemIndex: itemIndex, count: count) + } + ) self.entries = entries self.lower = lower diff --git a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift index bf18e4432b..d966bd7730 100644 --- a/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatChannelSubscriberInputPanelNode/Sources/ChatChannelSubscriberInputPanelNode.swift @@ -439,7 +439,7 @@ public final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode { self.giftButton.isHidden = true self.helpButton.isHidden = true } - self.giftButton.frame = CGRect(x: width - rightInset - panelHeight - 5.0, y: -3.0, width: panelHeight, height: panelHeight) + self.giftButton.frame = CGRect(x: width - rightInset - panelHeight - 5.0, y: 0.0, width: panelHeight, height: panelHeight) self.helpButton.frame = CGRect(x: width - rightInset - panelHeight, y: 0.0, width: panelHeight, height: panelHeight) } else { self.giftButton.isHidden = true diff --git a/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift index 1c6f4edbf2..ec6b77ffe8 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftSetupScreen/Sources/GiftSetupScreen.swift @@ -914,7 +914,7 @@ final class GiftSetupScreenComponent: Component { if let upgradeStars = gift.upgradeStars, component.peerId != component.context.account.peerId { let upgradeFooterRawString: String if isChannelGift { - upgradeFooterRawString = "Enable this to let the admins of \(peerName) turn your gift into a unique collectible. [Learn More >]()" + upgradeFooterRawString = environment.strings.Gift_SendChannel_Upgrade_Info(peerName).string } else { upgradeFooterRawString = environment.strings.Gift_Send_Upgrade_Info(peerName).string } diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index 5ed9485177..1cc47df5ab 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -1728,8 +1728,14 @@ private final class GiftViewSheetContent: CombinedComponent { valueAttributedString.addAttribute(.baselineOffset, value: 1.0, range: range) } + var canConvert = true + if let reference = subject.arguments?.reference, case let .peer(peerId, _) = reference { + if let peer = state.peerMap[peerId], case let .channel(channel) = peer, !channel.flags.contains(.isCreator) { + canConvert = false + } + } let valueComponent: AnyComponent - if let convertStars, incoming && !converted { + if let convertStars, incoming && !converted && canConvert { valueComponent = AnyComponent( HStack([ AnyComponentWithIdentity( @@ -2558,10 +2564,13 @@ public class GiftViewScreen: ViewControllerComponentContainer { self.dismissAnimated() + let giftsPeerId: EnginePeer.Id? let text: String - if arguments.peerId?.namespace == Namespaces.Peer.CloudChannel { + if case let .peer(peerId, _) = arguments.reference, peerId == Namespaces.Peer.CloudChannel { + giftsPeerId = peerId text = added ? presentationData.strings.Gift_Displayed_ChannelText : presentationData.strings.Gift_Hidden_ChannelText } else { + giftsPeerId = arguments.peerId text = added ? presentationData.strings.Gift_Displayed_NewText : presentationData.strings.Gift_Hidden_NewText } @@ -2573,8 +2582,8 @@ public class GiftViewScreen: ViewControllerComponentContainer { content: .sticker(context: context, file: animationFile, loop: false, title: nil, text: text, undoText: updateSavedToProfile == nil ? presentationData.strings.Gift_Displayed_View : nil, customAction: nil), elevatedLayout: lastController is ChatController, action: { [weak navigationController] action in - if case .undo = action, let navigationController { - let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId)) + if case .undo = action, let navigationController, let giftsPeerId { + let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: giftsPeerId)) |> deliverOnMainQueue).start(next: { [weak navigationController] peer in guard let peer, let navigationController else { return @@ -2583,7 +2592,7 @@ public class GiftViewScreen: ViewControllerComponentContainer { context: context, updatedPresentationData: nil, peer: peer._asPeer(), - mode: .myProfileGifts, + mode: giftsPeerId == context.account.peerId ? .myProfileGifts : .gifts, avatarInitiallyExpanded: false, fromChat: false, requestsContext: nil diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 0f4a735493..bddb6cad7c 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -4440,10 +4440,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro PeerInfoScreenImpl.openSavedMessagesMoreMenu(context: strongSelf.context, sourceController: controller, isViewingAsTopics: true, sourceView: source.view, gesture: gesture) } default: - break + strongSelf.displayMediaGalleryContextMenu(source: source, gesture: gesture) } - } else { - strongSelf.displayMediaGalleryContextMenu(source: source, gesture: gesture) } case .sort: guard let source else { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift index d7646e1bfc..e905b5b021 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoGiftsPaneNode.swift @@ -198,7 +198,7 @@ public final class PeerInfoGiftsPaneNode: ASDisplayNode, PeerInfoPaneNode, UIScr ribbonText = nil } case let .unique(gift): - ribbonText = params.presentationData.strings.PeerInfo_Gifts_OneOf(compactNumericCountString(Int(gift.availability.total), decimalSeparator: params.presentationData.dateTimeFormat.decimalSeparator)).string + ribbonText = params.presentationData.strings.PeerInfo_Gifts_OneOf(compactNumericCountString(Int(gift.availability.issued), decimalSeparator: params.presentationData.dateTimeFormat.decimalSeparator)).string for attribute in gift.attributes { if case let .backdrop(_, innerColor, outerColor, _, _, _) = attribute { ribbonColor = .custom(outerColor, innerColor) diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift index 39d7b106c6..7aaca4ddeb 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorScreen/Sources/ChannelAppearanceScreen.swift @@ -187,9 +187,7 @@ final class ChannelAppearanceScreenComponent: Component { private let emojiStatusSection = ComponentView() private let emojiPackSection = ComponentView() private let stickerPackSection = ComponentView() - - private var chatPreviewItemNode: PeerNameColorChatPreviewItemNode? - + private var isUpdating: Bool = false private var component: ChannelAppearanceScreenComponent? @@ -227,7 +225,6 @@ final class ChannelAppearanceScreenComponent: Component { private var applyDisposable: Disposable? private weak var emojiStatusSelectionController: ViewController? - private weak var currentUndoController: UndoOverlayController? override init(frame: CGRect) { self.scrollView = ScrollView() @@ -468,12 +465,7 @@ final class ChannelAppearanceScreenComponent: Component { self.displayBoostLevels(subject: requiredBoostSubject) return } - - if resolvedState.changes.isEmpty { - self.environment?.controller()?.dismiss() - return - } - + self.isApplyingSettings = true self.state?.updated(transition: .immediate) diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index 940f16e585..f75aeebc58 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -3230,6 +3230,8 @@ private func peerInfoControllerImpl(context: AccountContext, updatedPresentation forumTopicThread = thread case .myProfile: isMyProfile = true + case .gifts: + switchToGifts = true case .myProfileGifts: isMyProfile = true switchToGifts = true