diff --git a/submodules/AttachmentUI/Sources/AttachmentPanel.swift b/submodules/AttachmentUI/Sources/AttachmentPanel.swift index 651e5b6d1f..4ba6792a0b 100644 --- a/submodules/AttachmentUI/Sources/AttachmentPanel.swift +++ b/submodules/AttachmentUI/Sources/AttachmentPanel.swift @@ -1265,7 +1265,7 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate { }, addDoNotTranslateLanguage: { _ in }, hideTranslationPanel: { }, openPremiumGift: { - }, openSuggestPost: { _ in + }, openSuggestPost: { _, _ in }, openPremiumRequiredForMessaging: { }, openStarsPurchase: { _ in }, openMessagePayment: { diff --git a/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift b/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift index 84a3dfb9c1..bc7dbc2d85 100644 --- a/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift +++ b/submodules/ChatPresentationInterfaceState/Sources/ChatPanelInterfaceInteraction.swift @@ -62,6 +62,13 @@ public enum ChatTranslationDisplayType { } public final class ChatPanelInterfaceInteraction { + public enum OpenSuggestPostMode { + case `default` + case editMessage + case editTime + case editPrice + } + public let setupReplyMessage: (MessageId?, @escaping (ContainedViewLayoutTransition, @escaping () -> Void) -> Void) -> Void public let setupEditMessage: (MessageId?, @escaping (ContainedViewLayoutTransition) -> Void) -> Void public let beginMessageSelection: ([MessageId], @escaping (ContainedViewLayoutTransition) -> Void) -> Void @@ -168,7 +175,7 @@ public final class ChatPanelInterfaceInteraction { public let addDoNotTranslateLanguage: (String) -> Void public let hideTranslationPanel: () -> Void public let openPremiumGift: () -> Void - public let openSuggestPost: (Message?) -> Void + public let openSuggestPost: (Message?, OpenSuggestPostMode) -> Void public let openPremiumRequiredForMessaging: () -> Void public let openStarsPurchase: (Int64?) -> Void public let openMessagePayment: () -> Void @@ -291,7 +298,7 @@ public final class ChatPanelInterfaceInteraction { addDoNotTranslateLanguage: @escaping (String) -> Void, hideTranslationPanel: @escaping () -> Void, openPremiumGift: @escaping () -> Void, - openSuggestPost: @escaping (Message?) -> Void, + openSuggestPost: @escaping (Message?, OpenSuggestPostMode) -> Void, openPremiumRequiredForMessaging: @escaping () -> Void, openStarsPurchase: @escaping (Int64?) -> Void, openMessagePayment: @escaping () -> Void, @@ -544,7 +551,7 @@ public final class ChatPanelInterfaceInteraction { }, addDoNotTranslateLanguage: { _ in }, hideTranslationPanel: { }, openPremiumGift: { - }, openSuggestPost: { _ in + }, openSuggestPost: { _, _ in }, openPremiumRequiredForMessaging: { }, openStarsPurchase: { _ in }, openMessagePayment: { diff --git a/submodules/TelegramCore/Sources/State/PaidMessages.swift b/submodules/TelegramCore/Sources/State/PaidMessages.swift index 226710fec0..035dcf363c 100644 --- a/submodules/TelegramCore/Sources/State/PaidMessages.swift +++ b/submodules/TelegramCore/Sources/State/PaidMessages.swift @@ -107,6 +107,7 @@ func _internal_reinstateNoPaidMessagesException(account: Account, scopePeerId: P } var flags: Int32 = 0 flags |= (1 << 2) + flags |= (1 << 1) return account.network.request(Api.functions.account.toggleNoPaidMessagesException(flags: flags, parentPeer: scopeInputPeer, userId: inputUser)) |> `catch` { _ -> Signal in return .single(.boolFalse) diff --git a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift index c3c3e8bb96..1ccce6c161 100644 --- a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift +++ b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsController.swift @@ -165,7 +165,7 @@ public final class ChatRecentActionsController: TelegramBaseController { }, addDoNotTranslateLanguage: { _ in }, hideTranslationPanel: { }, openPremiumGift: { - }, openSuggestPost: { _ in + }, openSuggestPost: { _, _ in }, openPremiumRequiredForMessaging: { }, openStarsPurchase: { _ in }, openMessagePayment: { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 0f88b26a3e..d0e79cb506 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -430,7 +430,7 @@ final class PeerInfoSelectionPanelNode: ASDisplayNode { }, addDoNotTranslateLanguage: { _ in }, hideTranslationPanel: { }, openPremiumGift: { - }, openSuggestPost: { _ in + }, openSuggestPost: { _, _ in }, openPremiumRequiredForMessaging: { }, openStarsPurchase: { _ in }, openMessagePayment: { diff --git a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift index 190bb9afc2..360adb14eb 100644 --- a/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift +++ b/submodules/TelegramUI/Components/PeerSelectionController/Sources/PeerSelectionControllerNode.swift @@ -818,7 +818,7 @@ final class PeerSelectionControllerNode: ASDisplayNode { }, addDoNotTranslateLanguage: { _ in }, hideTranslationPanel: { }, openPremiumGift: { - }, openSuggestPost: { _ in + }, openSuggestPost: { _, _ in }, openPremiumRequiredForMessaging: { }, openStarsPurchase: { _ in }, openMessagePayment: { diff --git a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift index bf51e55999..5109478202 100644 --- a/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift +++ b/submodules/TelegramUI/Sources/Chat/ChatControllerLoadDisplayNode.swift @@ -4141,7 +4141,7 @@ extension ChatControllerImpl { }) self.push(controller) } - }, openSuggestPost: { [weak self] message in + }, openSuggestPost: { [weak self] message, mode in guard let self else { return } @@ -4198,6 +4198,13 @@ extension ChatControllerImpl { } return updated }) + + switch mode { + case .default, .editMessage: + break + case .editTime, .editPrice: + self.presentSuggestPostOptions() + } } else { self.updateChatPresentationInterfaceState(interactive: true, { state in var state = state @@ -4212,8 +4219,8 @@ extension ChatControllerImpl { } return state }) + self.presentSuggestPostOptions() } - self.presentSuggestPostOptions() }, openPremiumRequiredForMessaging: { [weak self] in guard let self else { return diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index bd3c917185..e8e6659451 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2374,7 +2374,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G ]), in: .window(.root)) } case 2: - strongSelf.interfaceInteraction?.openSuggestPost(message) + strongSelf.interfaceInteraction?.openSuggestPost(message, .default) default: break } diff --git a/submodules/TelegramUI/Sources/ChatControllerContentData.swift b/submodules/TelegramUI/Sources/ChatControllerContentData.swift index dca50cbee7..c7c8fe80d9 100644 --- a/submodules/TelegramUI/Sources/ChatControllerContentData.swift +++ b/submodules/TelegramUI/Sources/ChatControllerContentData.swift @@ -819,8 +819,10 @@ extension ChatControllerImpl { if let channel = peerView.peers[peerView.peerId] as? TelegramChannel { if channel.isMonoForum { if let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = peerView.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.manageDirect) { + } else if let sendPaidMessageStarsValue = cachedData.sendPaidMessageStars, sendPaidMessageStarsValue == .zero { + sendPaidMessageStars = nil } else { - sendPaidMessageStars = cachedData.sendPaidMessageStars + sendPaidMessageStars = channel.sendPaidMessageStars } } else { if channel.flags.contains(.isCreator) || channel.adminRights != nil { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index 259ba08efe..cd06f11f36 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -1521,13 +1521,37 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState if canSuggestPost { //TODO:localize - actions.append(.action(ContextMenuActionItem(text: "Suggest a Post", icon: { theme in - return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Customize"), color: theme.actionSheet.primaryTextColor) - }, action: { c, _ in - c?.dismiss(completion: { - interfaceInteraction.openSuggestPost(message) - }) - }))) + if message.attributes.contains(where: { $0 is SuggestedPostMessageAttribute }) { + actions.append(.action(ContextMenuActionItem(text: "Edit Message", icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Edit"), color: theme.actionSheet.primaryTextColor) + }, action: { c, _ in + c?.dismiss(completion: { + interfaceInteraction.openSuggestPost(message, .editMessage) + }) + }))) + actions.append(.action(ContextMenuActionItem(text: "Edit Time", icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Calendar"), color: theme.actionSheet.primaryTextColor) + }, action: { c, _ in + c?.dismiss(completion: { + interfaceInteraction.openSuggestPost(message, .editTime) + }) + }))) + actions.append(.action(ContextMenuActionItem(text: "Edit Price", icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/PriceTag"), color: theme.actionSheet.primaryTextColor) + }, action: { c, _ in + c?.dismiss(completion: { + interfaceInteraction.openSuggestPost(message, .editPrice) + }) + }))) + } else { + actions.append(.action(ContextMenuActionItem(text: "Suggest a Post", icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Customize"), color: theme.actionSheet.primaryTextColor) + }, action: { c, _ in + c?.dismiss(completion: { + interfaceInteraction.openSuggestPost(message, .default) + }) + }))) + } } } diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 8c87be008e..d2af18fb7d 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -4773,7 +4773,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch case .gift: self.interfaceInteraction?.openPremiumGift() case .suggestPost: - self.interfaceInteraction?.openSuggestPost(nil) + self.interfaceInteraction?.openSuggestPost(nil, .default) } break }