mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-26 05:00:48 +00:00
Various improvements
This commit is contained in:
parent
f2e96efdb5
commit
4513f7d2e4
@ -3542,7 +3542,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||||||
if suggestedPostInfoNode !== strongSelf.suggestedPostInfoNode {
|
if suggestedPostInfoNode !== strongSelf.suggestedPostInfoNode {
|
||||||
strongSelf.suggestedPostInfoNode?.removeFromSupernode()
|
strongSelf.suggestedPostInfoNode?.removeFromSupernode()
|
||||||
strongSelf.suggestedPostInfoNode = suggestedPostInfoNode
|
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)
|
let suggestedPostInfoFrame = CGRect(origin: CGPoint(x: floor((params.width - suggestedPostInfoSize.width) * 0.5), y: 4.0), size: suggestedPostInfoSize)
|
||||||
suggestedPostInfoNode.frame = suggestedPostInfoFrame
|
suggestedPostInfoNode.frame = suggestedPostInfoFrame
|
||||||
|
@ -291,7 +291,7 @@ public func canAddMessageReactions(message: Message) -> Bool {
|
|||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
switch action.action {
|
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
|
return false
|
||||||
default:
|
default:
|
||||||
return true
|
return true
|
||||||
|
@ -93,15 +93,82 @@ public final class ChatMessageSuggestedPostInfoNode: ASDisplayNode {
|
|||||||
|
|
||||||
//TODO:localize
|
//TODO:localize
|
||||||
let titleText: String
|
let titleText: String
|
||||||
if !item.message.effectivelyIncoming(item.context.account.peerId) {
|
if let attribute = item.message.attributes.first(where: { $0 is ReplyMessageAttribute }) as? ReplyMessageAttribute {
|
||||||
if item.message.attributes.contains(where: { $0 is ReplyMessageAttribute }) {
|
var changedText = false
|
||||||
titleText = "You suggest a new price,\ntime and text for this message."
|
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 {
|
} 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 {
|
} else {
|
||||||
if item.message.author is TelegramChannel {
|
if !item.message.effectivelyIncoming(item.context.account.peerId) {
|
||||||
titleText = "**\(item.message.author.flatMap(EnginePeer.init)?.compactDisplayTitle ?? " ")** suggests a new price,\ntime, and text for your message."
|
titleText = "You suggest to post\nthis message."
|
||||||
} else {
|
} else {
|
||||||
titleText = "**\(item.message.author.flatMap(EnginePeer.init)?.compactDisplayTitle ?? " ")** suggests to post\nthis message."
|
titleText = "**\(item.message.author.flatMap(EnginePeer.init)?.compactDisplayTitle ?? " ")** suggests to post\nthis message."
|
||||||
}
|
}
|
||||||
|
@ -2361,7 +2361,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
|
|
||||||
timestamp = Int32(Date().timeIntervalSince1970) + 1 * 60 * 60
|
timestamp = Int32(Date().timeIntervalSince1970) + 1 * 60 * 60
|
||||||
} else {
|
} 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:
|
case 2:
|
||||||
strongSelf.interfaceInteraction?.openSuggestPost(message)
|
strongSelf.interfaceInteraction?.openSuggestPost(message)
|
||||||
|
@ -820,12 +820,20 @@ extension ChatControllerImpl {
|
|||||||
if channel.isMonoForum {
|
if channel.isMonoForum {
|
||||||
if let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = peerView.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.manageDirect) {
|
if let linkedMonoforumId = channel.linkedMonoforumId, let mainChannel = peerView.peers[linkedMonoforumId] as? TelegramChannel, mainChannel.hasPermission(.manageDirect) {
|
||||||
} else {
|
} else {
|
||||||
sendPaidMessageStars = channel.sendPaidMessageStars
|
sendPaidMessageStars = cachedData.sendPaidMessageStars
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if channel.flags.contains(.isCreator) || channel.adminRights != nil {
|
if channel.flags.contains(.isCreator) || channel.adminRights != nil {
|
||||||
} else {
|
} else {
|
||||||
sendPaidMessageStars = channel.sendPaidMessageStars
|
if let personalSendPaidMessageStars = cachedData.sendPaidMessageStars {
|
||||||
|
if personalSendPaidMessageStars == .zero {
|
||||||
|
sendPaidMessageStars = nil
|
||||||
|
} else {
|
||||||
|
sendPaidMessageStars = personalSendPaidMessageStars
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sendPaidMessageStars = channel.sendPaidMessageStars
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
if let message = messages.first, message.id.namespace == Namespaces.Message.Cloud, let channel = message.peers[message.id.peerId] as? TelegramChannel, channel.isMonoForum {
|
||||||
//TODO:localize
|
var canSuggestPost = true
|
||||||
actions.append(.action(ContextMenuActionItem(text: "Suggest a Post", icon: { theme in
|
for media in message.media {
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Customize"), color: theme.actionSheet.primaryTextColor)
|
if media is TelegramMediaAction {
|
||||||
}, action: { c, _ in
|
canSuggestPost = false
|
||||||
c?.dismiss(completion: {
|
}
|
||||||
interfaceInteraction.openSuggestPost(message)
|
}
|
||||||
})
|
|
||||||
})))
|
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 {
|
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 let channel = chatPresentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isMonoForum, let associatedPeerId = channel.associatedPeerId {
|
||||||
if message.effectivelyIncoming(context.account.peerId), message.author?.id == associatedPeerId {
|
if message.effectivelyIncoming(context.account.peerId), message.author?.id == associatedPeerId {
|
||||||
canViewAuthor = true
|
canViewAuthor = true
|
||||||
|
for media in message.media {
|
||||||
|
if media is TelegramMediaAction {
|
||||||
|
canViewAuthor = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if let messageReadStatsAreHidden = infoSummaryData.messageReadStatsAreHidden, !messageReadStatsAreHidden {
|
} else if let messageReadStatsAreHidden = infoSummaryData.messageReadStatsAreHidden, !messageReadStatsAreHidden {
|
||||||
canViewStats = canViewReadStats(message: message, participantCount: infoSummaryData.participantCount, isMessageRead: isMessageRead, isPremium: isPremium, appConfig: appConfig)
|
canViewStats = canViewReadStats(message: message, participantCount: infoSummaryData.participantCount, isMessageRead: isMessageRead, isPremium: isPremium, appConfig: appConfig)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user