Various improvements

This commit is contained in:
Isaac 2025-06-24 17:27:17 +02:00
parent 183db2a8e4
commit 484c350538
11 changed files with 60 additions and 19 deletions

View File

@ -1265,7 +1265,7 @@ final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate {
}, addDoNotTranslateLanguage: { _ in }, addDoNotTranslateLanguage: { _ in
}, hideTranslationPanel: { }, hideTranslationPanel: {
}, openPremiumGift: { }, openPremiumGift: {
}, openSuggestPost: { _ in }, openSuggestPost: { _, _ in
}, openPremiumRequiredForMessaging: { }, openPremiumRequiredForMessaging: {
}, openStarsPurchase: { _ in }, openStarsPurchase: { _ in
}, openMessagePayment: { }, openMessagePayment: {

View File

@ -62,6 +62,13 @@ public enum ChatTranslationDisplayType {
} }
public final class ChatPanelInterfaceInteraction { 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 setupReplyMessage: (MessageId?, @escaping (ContainedViewLayoutTransition, @escaping () -> Void) -> Void) -> Void
public let setupEditMessage: (MessageId?, @escaping (ContainedViewLayoutTransition) -> Void) -> Void public let setupEditMessage: (MessageId?, @escaping (ContainedViewLayoutTransition) -> Void) -> Void
public let beginMessageSelection: ([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 addDoNotTranslateLanguage: (String) -> Void
public let hideTranslationPanel: () -> Void public let hideTranslationPanel: () -> Void
public let openPremiumGift: () -> Void public let openPremiumGift: () -> Void
public let openSuggestPost: (Message?) -> Void public let openSuggestPost: (Message?, OpenSuggestPostMode) -> Void
public let openPremiumRequiredForMessaging: () -> Void public let openPremiumRequiredForMessaging: () -> Void
public let openStarsPurchase: (Int64?) -> Void public let openStarsPurchase: (Int64?) -> Void
public let openMessagePayment: () -> Void public let openMessagePayment: () -> Void
@ -291,7 +298,7 @@ public final class ChatPanelInterfaceInteraction {
addDoNotTranslateLanguage: @escaping (String) -> Void, addDoNotTranslateLanguage: @escaping (String) -> Void,
hideTranslationPanel: @escaping () -> Void, hideTranslationPanel: @escaping () -> Void,
openPremiumGift: @escaping () -> Void, openPremiumGift: @escaping () -> Void,
openSuggestPost: @escaping (Message?) -> Void, openSuggestPost: @escaping (Message?, OpenSuggestPostMode) -> Void,
openPremiumRequiredForMessaging: @escaping () -> Void, openPremiumRequiredForMessaging: @escaping () -> Void,
openStarsPurchase: @escaping (Int64?) -> Void, openStarsPurchase: @escaping (Int64?) -> Void,
openMessagePayment: @escaping () -> Void, openMessagePayment: @escaping () -> Void,
@ -544,7 +551,7 @@ public final class ChatPanelInterfaceInteraction {
}, addDoNotTranslateLanguage: { _ in }, addDoNotTranslateLanguage: { _ in
}, hideTranslationPanel: { }, hideTranslationPanel: {
}, openPremiumGift: { }, openPremiumGift: {
}, openSuggestPost: { _ in }, openSuggestPost: { _, _ in
}, openPremiumRequiredForMessaging: { }, openPremiumRequiredForMessaging: {
}, openStarsPurchase: { _ in }, openStarsPurchase: { _ in
}, openMessagePayment: { }, openMessagePayment: {

View File

@ -107,6 +107,7 @@ func _internal_reinstateNoPaidMessagesException(account: Account, scopePeerId: P
} }
var flags: Int32 = 0 var flags: Int32 = 0
flags |= (1 << 2) flags |= (1 << 2)
flags |= (1 << 1)
return account.network.request(Api.functions.account.toggleNoPaidMessagesException(flags: flags, parentPeer: scopeInputPeer, userId: inputUser)) return account.network.request(Api.functions.account.toggleNoPaidMessagesException(flags: flags, parentPeer: scopeInputPeer, userId: inputUser))
|> `catch` { _ -> Signal<Api.Bool, NoError> in |> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse) return .single(.boolFalse)

View File

@ -165,7 +165,7 @@ public final class ChatRecentActionsController: TelegramBaseController {
}, addDoNotTranslateLanguage: { _ in }, addDoNotTranslateLanguage: { _ in
}, hideTranslationPanel: { }, hideTranslationPanel: {
}, openPremiumGift: { }, openPremiumGift: {
}, openSuggestPost: { _ in }, openSuggestPost: { _, _ in
}, openPremiumRequiredForMessaging: { }, openPremiumRequiredForMessaging: {
}, openStarsPurchase: { _ in }, openStarsPurchase: { _ in
}, openMessagePayment: { }, openMessagePayment: {

View File

@ -430,7 +430,7 @@ final class PeerInfoSelectionPanelNode: ASDisplayNode {
}, addDoNotTranslateLanguage: { _ in }, addDoNotTranslateLanguage: { _ in
}, hideTranslationPanel: { }, hideTranslationPanel: {
}, openPremiumGift: { }, openPremiumGift: {
}, openSuggestPost: { _ in }, openSuggestPost: { _, _ in
}, openPremiumRequiredForMessaging: { }, openPremiumRequiredForMessaging: {
}, openStarsPurchase: { _ in }, openStarsPurchase: { _ in
}, openMessagePayment: { }, openMessagePayment: {

View File

@ -818,7 +818,7 @@ final class PeerSelectionControllerNode: ASDisplayNode {
}, addDoNotTranslateLanguage: { _ in }, addDoNotTranslateLanguage: { _ in
}, hideTranslationPanel: { }, hideTranslationPanel: {
}, openPremiumGift: { }, openPremiumGift: {
}, openSuggestPost: { _ in }, openSuggestPost: { _, _ in
}, openPremiumRequiredForMessaging: { }, openPremiumRequiredForMessaging: {
}, openStarsPurchase: { _ in }, openStarsPurchase: { _ in
}, openMessagePayment: { }, openMessagePayment: {

View File

@ -4141,7 +4141,7 @@ extension ChatControllerImpl {
}) })
self.push(controller) self.push(controller)
} }
}, openSuggestPost: { [weak self] message in }, openSuggestPost: { [weak self] message, mode in
guard let self else { guard let self else {
return return
} }
@ -4198,6 +4198,13 @@ extension ChatControllerImpl {
} }
return updated return updated
}) })
switch mode {
case .default, .editMessage:
break
case .editTime, .editPrice:
self.presentSuggestPostOptions()
}
} else { } else {
self.updateChatPresentationInterfaceState(interactive: true, { state in self.updateChatPresentationInterfaceState(interactive: true, { state in
var state = state var state = state
@ -4212,8 +4219,8 @@ extension ChatControllerImpl {
} }
return state return state
}) })
}
self.presentSuggestPostOptions() self.presentSuggestPostOptions()
}
}, openPremiumRequiredForMessaging: { [weak self] in }, openPremiumRequiredForMessaging: { [weak self] in
guard let self else { guard let self else {
return return

View File

@ -2374,7 +2374,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
]), in: .window(.root)) ]), in: .window(.root))
} }
case 2: case 2:
strongSelf.interfaceInteraction?.openSuggestPost(message) strongSelf.interfaceInteraction?.openSuggestPost(message, .default)
default: default:
break break
} }

View File

@ -819,8 +819,10 @@ extension ChatControllerImpl {
if let channel = peerView.peers[peerView.peerId] as? TelegramChannel { if let channel = peerView.peers[peerView.peerId] as? TelegramChannel {
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 if let sendPaidMessageStarsValue = cachedData.sendPaidMessageStars, sendPaidMessageStarsValue == .zero {
sendPaidMessageStars = nil
} else { } else {
sendPaidMessageStars = cachedData.sendPaidMessageStars sendPaidMessageStars = channel.sendPaidMessageStars
} }
} else { } else {
if channel.flags.contains(.isCreator) || channel.adminRights != nil { if channel.flags.contains(.isCreator) || channel.adminRights != nil {

View File

@ -1521,15 +1521,39 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
if canSuggestPost { if canSuggestPost {
//TODO:localize //TODO:localize
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 actions.append(.action(ContextMenuActionItem(text: "Suggest a Post", icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Customize"), color: theme.actionSheet.primaryTextColor) return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Customize"), color: theme.actionSheet.primaryTextColor)
}, action: { c, _ in }, action: { c, _ in
c?.dismiss(completion: { c?.dismiss(completion: {
interfaceInteraction.openSuggestPost(message) interfaceInteraction.openSuggestPost(message, .default)
}) })
}))) })))
} }
} }
}
if let activePoll = activePoll, let voters = activePoll.results.voters { if let activePoll = activePoll, let voters = activePoll.results.voters {
var hasSelected = false var hasSelected = false

View File

@ -4773,7 +4773,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
case .gift: case .gift:
self.interfaceInteraction?.openPremiumGift() self.interfaceInteraction?.openPremiumGift()
case .suggestPost: case .suggestPost:
self.interfaceInteraction?.openSuggestPost(nil) self.interfaceInteraction?.openSuggestPost(nil, .default)
} }
break break
} }