mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-17 09:10:30 +00:00
Don't show Spoiler format option in secret chats
This commit is contained in:
parent
80e2fc02ee
commit
d60d2beaa4
@ -9798,7 +9798,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
private func getCaptionPanelView() -> TGCaptionPanelView {
|
||||
let presentationData = self.presentationData.withUpdated(theme: defaultDarkColorPresentationTheme)
|
||||
var presentationInterfaceState = ChatPresentationInterfaceState(chatWallpaper: .builtin(WallpaperSettings()), theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, limitsConfiguration: self.context.currentLimitsConfiguration.with { $0 }, fontSize: presentationData.chatFontSize, bubbleCorners: presentationData.chatBubbleCorners, accountPeerId: self.context.account.peerId, mode: .standard(previewing: false), chatLocation: .peer(PeerId(0)), subject: nil, peerNearbyData: nil, greetingData: nil, pendingUnpinnedAllMessages: false, activeGroupCallInfo: nil, hasActiveGroupCall: false, importState: nil)
|
||||
var presentationInterfaceState = ChatPresentationInterfaceState(chatWallpaper: .builtin(WallpaperSettings()), theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, limitsConfiguration: self.context.currentLimitsConfiguration.with { $0 }, fontSize: presentationData.chatFontSize, bubbleCorners: presentationData.chatBubbleCorners, accountPeerId: self.context.account.peerId, mode: .standard(previewing: false), chatLocation: self.presentationInterfaceState.chatLocation, subject: nil, peerNearbyData: nil, greetingData: nil, pendingUnpinnedAllMessages: false, activeGroupCallInfo: nil, hasActiveGroupCall: false, importState: nil)
|
||||
|
||||
var updateChatPresentationInterfaceStateImpl: (((ChatPresentationInterfaceState) -> ChatPresentationInterfaceState) -> Void)?
|
||||
var ensureFocusedImpl: (() -> Void)?
|
||||
|
@ -17,6 +17,8 @@ final class ChatTextInputMenu {
|
||||
private var stringUnderline: String = "Underline"
|
||||
private var stringSpoiler: String = "Spoiler"
|
||||
|
||||
private let hasSpoilers: Bool
|
||||
|
||||
private(set) var state: ChatTextInputMenuState = .inactive {
|
||||
didSet {
|
||||
if self.state != oldValue {
|
||||
@ -26,8 +28,7 @@ final class ChatTextInputMenu {
|
||||
case .general:
|
||||
UIMenuController.shared.menuItems = []
|
||||
case .format:
|
||||
UIMenuController.shared.menuItems = [
|
||||
UIMenuItem(title: self.stringSpoiler, action: Selector(("formatAttributesSpoiler:"))),
|
||||
var menuItems: [UIMenuItem] = [
|
||||
UIMenuItem(title: self.stringBold, action: Selector(("formatAttributesBold:"))),
|
||||
UIMenuItem(title: self.stringItalic, action: Selector(("formatAttributesItalic:"))),
|
||||
UIMenuItem(title: self.stringMonospace, action: Selector(("formatAttributesMonospace:"))),
|
||||
@ -35,6 +36,10 @@ final class ChatTextInputMenu {
|
||||
UIMenuItem(title: self.stringStrikethrough, action: Selector(("formatAttributesStrikethrough:"))),
|
||||
UIMenuItem(title: self.stringUnderline, action: Selector(("formatAttributesUnderline:")))
|
||||
]
|
||||
if self.hasSpoilers {
|
||||
menuItems.insert(UIMenuItem(title: self.stringSpoiler, action: Selector(("formatAttributesSpoiler:"))), at: 0)
|
||||
}
|
||||
UIMenuController.shared.menuItems = menuItems
|
||||
}
|
||||
|
||||
}
|
||||
@ -43,7 +48,8 @@ final class ChatTextInputMenu {
|
||||
|
||||
private var observer: NSObjectProtocol?
|
||||
|
||||
init() {
|
||||
init(hasSpoilers: Bool = false) {
|
||||
self.hasSpoilers = hasSpoilers
|
||||
self.observer = NotificationCenter.default.addObserver(forName: UIMenuController.didHideMenuNotification, object: nil, queue: nil, using: { [weak self] _ in
|
||||
self?.back()
|
||||
})
|
||||
|
@ -296,7 +296,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
|
||||
var isMediaDeleted: Bool = false
|
||||
|
||||
private let inputMenu = ChatTextInputMenu()
|
||||
private let inputMenu: ChatTextInputMenu
|
||||
|
||||
private var theme: PresentationTheme?
|
||||
private var strings: PresentationStrings?
|
||||
@ -451,6 +451,12 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
init(presentationInterfaceState: ChatPresentationInterfaceState, presentationContext: ChatPresentationContext?, presentController: @escaping (ViewController) -> Void) {
|
||||
self.presentationInterfaceState = presentationInterfaceState
|
||||
|
||||
var hasSpoilers = true
|
||||
if presentationInterfaceState.chatLocation.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
hasSpoilers = false
|
||||
}
|
||||
self.inputMenu = ChatTextInputMenu(hasSpoilers: hasSpoilers)
|
||||
|
||||
self.clippingNode = ASDisplayNode()
|
||||
self.clippingNode.clipsToBounds = true
|
||||
|
||||
|
@ -141,7 +141,7 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
private var presentationInterfaceState: ChatPresentationInterfaceState?
|
||||
private var initializedPlaceholder = false
|
||||
|
||||
private let inputMenu = ChatTextInputMenu()
|
||||
private let inputMenu: ChatTextInputMenu
|
||||
|
||||
private var theme: PresentationTheme?
|
||||
private var strings: PresentationStrings?
|
||||
@ -241,6 +241,12 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
|
||||
self.presentationInterfaceState = presentationInterfaceState
|
||||
self.isCaption = isCaption
|
||||
|
||||
var hasSpoilers = true
|
||||
if presentationInterfaceState.chatLocation.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
hasSpoilers = false
|
||||
}
|
||||
self.inputMenu = ChatTextInputMenu(hasSpoilers: hasSpoilers)
|
||||
|
||||
self.textInputContainerBackgroundNode = ASImageNode()
|
||||
self.textInputContainerBackgroundNode.isUserInteractionEnabled = false
|
||||
self.textInputContainerBackgroundNode.displaysAsynchronously = false
|
||||
|
Loading…
x
Reference in New Issue
Block a user