Various improvements

This commit is contained in:
Ilya Laktyushin 2024-09-03 18:26:47 +04:00
parent 7e57a166dc
commit 3cdfb2031d
5 changed files with 36 additions and 6 deletions

View File

@ -1010,7 +1010,8 @@ public protocol ChatController: ViewController {
var canReadHistory: ValuePromise<Bool> { get }
var parentController: ViewController? { get set }
var customNavigationController: NavigationController? { get set }
var dismissPreviewing: (() -> Void)? { get set }
var purposefulAction: (() -> Void)? { get set }
var stateUpdated: ((ContainedViewLayoutTransition) -> Void)? { get set }

View File

@ -1402,17 +1402,26 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
strongSelf.presentInGlobalOverlay(contextController)
}
} else {
var dismissPreviewingImpl: (() -> Void)?
let source: ContextContentSource
if let location = location {
source = .location(ChatListContextLocationContentSource(controller: strongSelf, location: location))
} else {
let chatController = strongSelf.context.sharedContext.makeChatController(context: strongSelf.context, chatLocation: .peer(id: peer.peerId), subject: nil, botStart: nil, mode: .standard(.previewing), params: nil)
chatController.customNavigationController = strongSelf.navigationController as? NavigationController
chatController.canReadHistory.set(false)
chatController.dismissPreviewing = {
dismissPreviewingImpl?()
}
source = .controller(ContextControllerContentSourceImpl(controller: chatController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController))
}
let contextController = ContextController(presentationData: strongSelf.presentationData, source: source, items: chatContextMenuItems(context: strongSelf.context, peerId: peer.peerId, promoInfo: promoInfo, source: .chatList(filter: strongSelf.chatListDisplayNode.mainContainerNode.currentItemNode.chatListFilter), chatListController: strongSelf, joined: joined) |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
strongSelf.presentInGlobalOverlay(contextController)
dismissPreviewingImpl = { [weak contextController] in
contextController?.dismiss()
}
}
case let .forum(pinnedIndex, _, threadId, _, _):
let isPinned: Bool

View File

@ -387,6 +387,7 @@ extension ChatControllerImpl {
|> take(1)
|> deliverOnMainQueue).startStrict(next: { [weak self] peerView in
if let strongSelf = self, let peer = peerView.peers[peerView.peerId], peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil && !strongSelf.presentationInterfaceState.isNotAccessible {
if peer.id == strongSelf.context.account.peerId {
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer, let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: true, requestsContext: nil) {
strongSelf.effectiveNavigationController?.pushViewController(infoController)
@ -403,6 +404,8 @@ extension ChatControllerImpl {
strongSelf.effectiveNavigationController?.pushViewController(infoController)
}
}
strongSelf.dismissPreviewing?()
}
}))
case .replyThread:

View File

@ -567,6 +567,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var scheduledScrollToMessageId: (MessageId, NavigateToMessageParams)?
public var purposefulAction: (() -> Void)?
public var dismissPreviewing: (() -> Void)?
var updatedClosedPinnedMessageId: ((MessageId) -> Void)?
var requestedUnpinAllMessages: ((Int, MessageId) -> Void)?
@ -4653,7 +4655,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.navigationItem.titleView = self.chatTitleView
self.chatTitleView?.longPressed = { [weak self] in
if let strongSelf = self, let peerView = strongSelf.peerView, let peer = peerView.peers[peerView.peerId], peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil && !strongSelf.presentationInterfaceState.isNotAccessible {
strongSelf.interfaceInteraction?.beginMessageSearch(.everything, "")
if case .standard(.previewing) = strongSelf.mode {
} else {
strongSelf.interfaceInteraction?.beginMessageSearch(.everything, "")
}
}
}
@ -5414,7 +5419,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
imageOverride = nil
}
(strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.setPeer(context: strongSelf.context, theme: strongSelf.presentationData.theme, peer: EnginePeer(peer), overrideImage: imageOverride)
(strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.contextActionIsEnabled = peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil
if case .standard(.previewing) = strongSelf.mode {
(strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.contextActionIsEnabled = false
} else {
(strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.contextActionIsEnabled = peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil
}
strongSelf.chatInfoNavigationButton?.buttonItem.accessibilityLabel = presentationInterfaceState.strings.Conversation_ContextMenuOpenProfile
strongSelf.storyStats = peerView.storyStats
@ -6304,7 +6313,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if strongSelf.isNodeLoaded {
strongSelf.chatDisplayNode.overlayTitle = strongSelf.overlayTitle
}
(strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.contextActionIsEnabled = true
if case .standard(.previewing) = strongSelf.mode {
(strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.contextActionIsEnabled = false
} else {
(strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.contextActionIsEnabled = true
}
var peerDiscussionId: PeerId?
var peerGeoLocation: PeerGeoLocation?
@ -8368,7 +8381,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
@objc func rightNavigationButtonAction() {
if let button = self.rightNavigationButton {
if case let .peer(peerId) = self.chatLocation, case .openChatInfo(expandAvatar: true, _) = button.action, let storyStats = self.storyStats, storyStats.unseenCount != 0, let avatarNode = self.avatarNode {
if case .standard(.previewing) = self.mode {
self.navigationButtonAction(button.action)
} else if case let .peer(peerId) = self.chatLocation, case .openChatInfo(expandAvatar: true, _) = button.action, let storyStats = self.storyStats, storyStats.unseenCount != 0, let avatarNode = self.avatarNode {
self.openStories(peerId: peerId, avatarHeaderNode: nil, avatarNode: avatarNode.avatarNode)
} else {
self.navigationButtonAction(button.action)

View File

@ -3684,7 +3684,9 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
}
}
}
if let navigationBar = self.navigationBar, let result = navigationBar.view.hitTest(self.view.convert(point, to: navigationBar.view), with: nil) {
return result
}
if let result = self.historyNode.view.hitTest(self.view.convert(point, to: self.historyNode.view), with: event), let node = result.asyncdisplaykit_node, node is ChatMessageSelectionNode || node is GridMessageSelectionNode {
return result
}