diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index cf5fa73d75..a403045005 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -3542,7 +3542,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI if suggestedPostInfoNode !== strongSelf.suggestedPostInfoNode { strongSelf.suggestedPostInfoNode?.removeFromSupernode() strongSelf.suggestedPostInfoNode = suggestedPostInfoNode - strongSelf.mainContextSourceNode.contentNode.addSubnode(suggestedPostInfoNode) + strongSelf.addSubnode(suggestedPostInfoNode) } let suggestedPostInfoFrame = CGRect(origin: CGPoint(x: floor((params.width - suggestedPostInfoSize.width) * 0.5), y: 4.0), size: suggestedPostInfoSize) suggestedPostInfoNode.frame = suggestedPostInfoFrame diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift index 1b79cf3821..bbdb19ca9a 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemCommon/Sources/ChatMessageItemCommon.swift @@ -291,7 +291,7 @@ public func canAddMessageReactions(message: Message) -> Bool { return true } else { switch action.action { - case .unknown, .groupCreated, .channelMigratedFromGroup, .groupMigratedToChannel, .historyCleared, .customText, .botDomainAccessGranted, .botAppAccessGranted, .botSentSecureValues, .phoneNumberRequest, .webViewData, .topicCreated, .attachMenuBotAllowed, .requestedPeer, .giveawayLaunched: + case .unknown, .groupCreated, .channelMigratedFromGroup, .groupMigratedToChannel, .historyCleared, .customText, .botDomainAccessGranted, .botAppAccessGranted, .botSentSecureValues, .phoneNumberRequest, .webViewData, .topicCreated, .attachMenuBotAllowed, .requestedPeer, .giveawayLaunched, .suggestedPostApprovalStatus: return false default: return true diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageSuggestedPostInfoNode/Sources/ChatMessageSuggestedPostInfoNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageSuggestedPostInfoNode/Sources/ChatMessageSuggestedPostInfoNode.swift index 1dc6273fdd..8c9f2407a3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageSuggestedPostInfoNode/Sources/ChatMessageSuggestedPostInfoNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageSuggestedPostInfoNode/Sources/ChatMessageSuggestedPostInfoNode.swift @@ -93,15 +93,82 @@ public final class ChatMessageSuggestedPostInfoNode: ASDisplayNode { //TODO:localize let titleText: String - if !item.message.effectivelyIncoming(item.context.account.peerId) { - if item.message.attributes.contains(where: { $0 is ReplyMessageAttribute }) { - titleText = "You suggest a new price,\ntime and text for this message." + if let attribute = item.message.attributes.first(where: { $0 is ReplyMessageAttribute }) as? ReplyMessageAttribute { + var changedText = false + var changedMedia = false + var changedTime = false + var changedPrice = false + if let previousMessage = item.message.associatedMessages[attribute.messageId] { + if previousMessage.text != item.message.text { + changedText = true + } + let filteredMediaIds = item.message.media.compactMap { media -> EngineMedia.Id? in + if media is TelegramMediaImage || media is TelegramMediaFile { + return media.id + } else { + return nil + } + } + let filteredPreviousMediaIds = previousMessage.media.compactMap { media -> EngineMedia.Id? in + if media is TelegramMediaImage || media is TelegramMediaFile { + return media.id + } else { + return nil + } + } + if Set(filteredPreviousMediaIds) != Set(filteredMediaIds) { + changedMedia = true + } + if let previousAttribute = previousMessage.attributes.first(where: { $0 is SuggestedPostMessageAttribute }) as? SuggestedPostMessageAttribute { + if previousAttribute.amount != amount { + changedPrice = true + } + if previousAttribute.timestamp != timestamp { + changedTime = true + } + } + } + + if !item.message.effectivelyIncoming(item.context.account.peerId) { + if changedText && changedMedia && changedPrice && changedTime { + titleText = "You suggest a new price,\ntime and contents for this message." + } else if changedText && changedPrice && changedTime { + titleText = "You suggest a new price,\ntime and text for this message." + } else if changedMedia && changedPrice && changedTime { + titleText = "You suggest a new price,\ntime and attachments for this message." + } else if changedPrice && changedTime { + titleText = "You suggest a new price and time\nfor this message." + } else if changedPrice { + titleText = "You suggest a new price\nfor this message." + } else if changedTime { + titleText = "You suggest a new time\nfor this message." + } else { + titleText = "You suggest changes\nfor this message." + } } else { - titleText = "You suggest to post\nthis message." + var channelName = "" + if item.message.author is TelegramChannel { + channelName = item.message.author.flatMap(EnginePeer.init)?.compactDisplayTitle ?? " " + } + if changedText && changedMedia && changedPrice && changedTime { + titleText = "**\(channelName)** suggests a new price,\ntime and contents for this message." + } else if changedText && changedPrice && changedTime { + titleText = "**\(channelName)** suggests a new price,\ntime and text for this message." + } else if changedMedia && changedPrice && changedTime { + titleText = "**\(channelName)** suggests a new price,\ntime and attachments for this message." + } else if changedPrice && changedTime { + titleText = "**\(channelName)** suggests a new price and time\nfor this message." + } else if changedPrice { + titleText = "**\(channelName)** suggests a new price\nfor this message." + } else if changedTime { + titleText = "**\(channelName)** suggests a new time\nfor this message." + } else { + titleText = "**\(channelName)** suggests changes\nfor this message." + } } } else { - if item.message.author is TelegramChannel { - titleText = "**\(item.message.author.flatMap(EnginePeer.init)?.compactDisplayTitle ?? " ")** suggests a new price,\ntime, and text for your message." + if !item.message.effectivelyIncoming(item.context.account.peerId) { + titleText = "You suggest to post\nthis message." } else { titleText = "**\(item.message.author.flatMap(EnginePeer.init)?.compactDisplayTitle ?? " ")** suggests to post\nthis message." } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index e28478e01a..bd3c917185 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2361,7 +2361,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G timestamp = Int32(Date().timeIntervalSince1970) + 1 * 60 * 60 } else { - let _ = strongSelf.context.engine.messages.monoforumPerformSuggestedPostAction(id: message.id, action: .approve(timestamp: timestamp)).startStandalone() + //TODO:localize + let textString = "Publish this message now?" + strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: nil, text: textString, actions: [ + TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {}), + TextAlertAction(type: .defaultAction, title: "Publish", action: { [weak strongSelf] in + guard let strongSelf else { + return + } + let _ = strongSelf.context.engine.messages.monoforumPerformSuggestedPostAction(id: message.id, action: .approve(timestamp: timestamp)).startStandalone() + }) + ]), in: .window(.root)) } case 2: strongSelf.interfaceInteraction?.openSuggestPost(message) diff --git a/submodules/TelegramUI/Sources/ChatControllerContentData.swift b/submodules/TelegramUI/Sources/ChatControllerContentData.swift index a6f8845dfe..dca50cbee7 100644 --- a/submodules/TelegramUI/Sources/ChatControllerContentData.swift +++ b/submodules/TelegramUI/Sources/ChatControllerContentData.swift @@ -820,12 +820,20 @@ extension ChatControllerImpl { if channel.isMonoForum { if let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = peerView.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.manageDirect) { } else { - sendPaidMessageStars = channel.sendPaidMessageStars + sendPaidMessageStars = cachedData.sendPaidMessageStars } } else { if channel.flags.contains(.isCreator) || channel.adminRights != nil { } else { - sendPaidMessageStars = channel.sendPaidMessageStars + if let personalSendPaidMessageStars = cachedData.sendPaidMessageStars { + if personalSendPaidMessageStars == .zero { + sendPaidMessageStars = nil + } else { + sendPaidMessageStars = personalSendPaidMessageStars + } + } else { + sendPaidMessageStars = channel.sendPaidMessageStars + } } } } diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index a51b38f894..259ba08efe 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -1512,14 +1512,23 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState } if let message = messages.first, message.id.namespace == Namespaces.Message.Cloud, let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.isMonoForum { - //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) - }) - }))) + var canSuggestPost = true + for media in message.media { + if media is TelegramMediaAction { + canSuggestPost = false + } + } + + 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 let activePoll = activePoll, let voters = activePoll.results.voters { @@ -1935,6 +1944,11 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState if let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isMonoForum, let associatedPeerId = channel.associatedPeerId { if message.effectivelyIncoming(context.account.peerId), message.author?.id == associatedPeerId { canViewAuthor = true + for media in message.media { + if media is TelegramMediaAction { + canViewAuthor = false + } + } } } else if let messageReadStatsAreHidden = infoSummaryData.messageReadStatsAreHidden, !messageReadStatsAreHidden { canViewStats = canViewReadStats(message: message, participantCount: infoSummaryData.participantCount, isMessageRead: isMessageRead, isPremium: isPremium, appConfig: appConfig)