diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 98ca92e802..da9ccc66f7 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -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)? diff --git a/submodules/TelegramUI/Sources/ChatTextInputMenu.swift b/submodules/TelegramUI/Sources/ChatTextInputMenu.swift index 81fedc3d29..402145b38e 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputMenu.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputMenu.swift @@ -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() }) diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 6f28bbcbda..38ca07e01b 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -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 diff --git a/submodules/TelegramUI/Sources/PeerSelectionTextInputPanelNode.swift b/submodules/TelegramUI/Sources/PeerSelectionTextInputPanelNode.swift index f1a3b97b39..775e22681c 100644 --- a/submodules/TelegramUI/Sources/PeerSelectionTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/PeerSelectionTextInputPanelNode.swift @@ -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