Various fixes

This commit is contained in:
Ilya Laktyushin 2022-11-09 22:00:38 +04:00
parent 117a1f6c22
commit 04bde13821
9 changed files with 89 additions and 50 deletions

View File

@ -3237,10 +3237,17 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
override public func toolbarActionSelected(action: ToolbarActionOption) {
let peerIds = self.chatListDisplayNode.containerNode.currentItemNode.currentState.selectedPeerIds
let threadIds = self.chatListDisplayNode.containerNode.currentItemNode.currentState.selectedThreadIds
if case .left = action {
let signal: Signal<Never, NoError>
var completion: (() -> Void)?
if !peerIds.isEmpty {
if !threadIds.isEmpty, case let .forum(peerId) = self.location {
self.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingItemId(ChatListNodeState.ItemId(peerId: peerId, threadId: threadIds.first!))
completion = { [weak self] in
self?.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingItemId(nil)
}
signal = self.context.engine.messages.markForumThreadsAsRead(peerId: peerId, threadIds: Array(threadIds))
} else if !peerIds.isEmpty {
self.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingItemId(ChatListNodeState.ItemId(peerId: peerIds.first!, threadId: nil))
completion = { [weak self] in
self?.chatListDisplayNode.containerNode.currentItemNode.setCurrentRemovingItemId(nil)

View File

@ -59,17 +59,31 @@ func chatListSelectionOptions(context: AccountContext, peerIds: Set<PeerId>, fil
func forumSelectionOptions(context: AccountContext, peerId: PeerId, threadIds: Set<Int64>, canDelete: Bool) -> Signal<ChatListSelectionOptions, NoError> {
let threadIdsArray = Array(threadIds)
var threadSignals: [Signal<MessageHistoryThreadData?, NoError>] = []
for threadId in threadIdsArray {
threadSignals.append(
context.engine.data.get(TelegramEngine.EngineData.Item.Peer.ThreadData(id: peerId, threadId: threadId))
)
}
return combineLatest(threadSignals)
|> map { threadDatas -> ChatListSelectionOptions in
if threadIds.isEmpty {
return context.engine.data.subscribe(TelegramEngine.EngineData.Item.Messages.PeerReadCounters(id: peerId))
|> map { counters -> ChatListSelectionOptions in
var hasUnread = false
if counters.isUnread {
hasUnread = true
}
return ChatListSelectionOptions(read: .all(enabled: hasUnread), delete: false)
}
|> distinctUntilChanged
return ChatListSelectionOptions(read: .selective(enabled: false), delete: false)
} else {
return .single(ChatListSelectionOptions(read: .selective(enabled: false), delete: canDelete))
var hasUnread = false
for thread in threadDatas {
guard let thread = thread else {
continue
}
if thread.incomingUnreadCount > 0 {
hasUnread = true
break
}
}
return ChatListSelectionOptions(read: .selective(enabled: hasUnread), delete: canDelete)
}
}
}

View File

@ -196,19 +196,10 @@ public final class TapLongTapOrDoubleTapGestureRecognizer: UIGestureRecognizer,
self.highlight?(touchLocation)
}
if let hitResult = self.view?.hitTest(touch.location(in: self.view), with: event) {
var fail = false
if let _ = hitResult as? UIButton {
fail = true
} else if let node = hitResult.asyncdisplaykit_node, node is ASControlNode {
fail = true
}
if fail {
if let hitResult = self.view?.hitTest(touch.location(in: self.view), with: event), let _ = hitResult as? UIButton {
self.state = .failed
return
}
}
self.tapCount += 1
if self.tapCount == 2 && self.touchCount == 1 {

View File

@ -472,6 +472,15 @@ public extension TelegramEngine {
|> ignoreValues
}
public func markForumThreadsAsRead(peerId: EnginePeer.Id, threadIds: [Int64]) -> Signal<Never, NoError> {
return self.account.postbox.transaction { transaction -> Void in
for threadId in threadIds {
_internal_markForumThreadAsReadInteractively(transaction: transaction, network: self.account.network, viewTracker: self.account.viewTracker, peerId: peerId, threadId: threadId)
}
}
|> ignoreValues
}
public func debugAddHoles() -> Signal<Never, NoError> {
return self.account.postbox.transaction { transaction -> Void in
transaction.addHolesEverywhere(peerNamespaces: [Namespaces.Peer.CloudUser, Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel], holeNamespace: Namespaces.Message.Cloud)

View File

@ -392,6 +392,11 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if let shareButtonNode = strongSelf.shareButtonNode, shareButtonNode.frame.contains(point) {
return .fail
}
if let threadInfoNode = strongSelf.threadInfoNode, threadInfoNode.frame.contains(point) {
if let _ = threadInfoNode.hitTest(strongSelf.view.convert(point, to: threadInfoNode.view), with: nil) {
return .fail
}
}
if let reactionButtonsNode = strongSelf.reactionButtonsNode {
if let _ = reactionButtonsNode.hitTest(strongSelf.view.convert(point, to: reactionButtonsNode.view), with: nil) {
return .fail
@ -2492,13 +2497,14 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
if let shareButtonNode = self.shareButtonNode, shareButtonNode.frame.contains(point) {
return shareButtonNode.view
}
if let threadInfoNode = self.threadInfoNode, let result = threadInfoNode.hitTest(self.view.convert(point, to: threadInfoNode.view), with: event) {
return result
}
if let reactionButtonsNode = self.reactionButtonsNode {
if let result = reactionButtonsNode.hitTest(self.view.convert(point, to: reactionButtonsNode.view), with: event) {
return result
}
}
return super.hitTest(point, with: event)
}

View File

@ -1968,6 +1968,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
hasReply = false
}
if !mergedTop.merged {
if headerSize.height.isZero {
headerSize.height += 14.0
} else {
@ -1991,6 +1992,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
headerSize.width = max(headerSize.width, threadInfoSizeApply.0.width + layoutConstants.text.bubbleInsets.left + layoutConstants.text.bubbleInsets.right)
headerSize.height += threadInfoSizeApply.0.height + 5.0
}
}
if !isInstantVideo, let replyMessage = replyMessage, hasReply {
if headerSize.height.isZero {

View File

@ -121,6 +121,11 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs
}
}
var sameThread = true
if lhs.threadId != rhs.threadId {
sameThread = false
}
var sameAuthor = false
if lhsEffectiveAuthor?.id == rhsEffectiveAuthor?.id && lhs.effectivelyIncoming(accountPeerId) == rhs.effectivelyIncoming(accountPeerId) {
sameAuthor = true
@ -155,7 +160,7 @@ private func messagesShouldBeMerged(accountPeerId: PeerId, _ lhs: Message, _ rhs
}
}
if abs(lhsEffectiveTimestamp - rhsEffectiveTimestamp) < Int32(10 * 60) && sameAuthor {
if abs(lhsEffectiveTimestamp - rhsEffectiveTimestamp) < Int32(10 * 60) && sameAuthor && sameThread {
if let channel = lhs.peers[lhs.id.peerId] as? TelegramChannel, case .group = channel.info, lhsEffectiveAuthor?.id == channel.id, !lhs.effectivelyIncoming(accountPeerId) {
return .none
}

View File

@ -192,7 +192,11 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if let shareButtonNode = strongSelf.shareButtonNode, shareButtonNode.frame.contains(point) {
return .fail
}
if let threadInfoNode = strongSelf.threadInfoNode, threadInfoNode.frame.contains(point) {
if let _ = threadInfoNode.hitTest(strongSelf.view.convert(point, to: threadInfoNode.view), with: nil) {
return .fail
}
}
if let reactionButtonsNode = strongSelf.reactionButtonsNode {
if let _ = reactionButtonsNode.hitTest(strongSelf.view.convert(point, to: reactionButtonsNode.view), with: nil) {
return .fail
@ -1444,13 +1448,14 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
if let shareButtonNode = self.shareButtonNode, shareButtonNode.frame.contains(point) {
return shareButtonNode.view
}
if let threadInfoNode = self.threadInfoNode, let result = threadInfoNode.hitTest(self.view.convert(point, to: threadInfoNode.view), with: event) {
return result
}
if let reactionButtonsNode = self.reactionButtonsNode {
if let result = reactionButtonsNode.hitTest(self.view.convert(point, to: reactionButtonsNode.view), with: event) {
return result
}
}
return super.hitTest(point, with: event)
}

View File

@ -334,7 +334,7 @@ class ChatMessageThreadInfoNode: ASDisplayNode {
let colors = topicIconColors(for: topicIconColor)
backgroundColor = UIColor(rgb: colors.0.last ?? 0x000000)
textColor = UIColor(rgb: colors.1.first ?? 0x000000)
arrowIcon = PresentationResourcesChat.chatBubbleArrowImage(color: textColor)
arrowIcon = PresentationResourcesChat.chatBubbleArrowImage(color: textColor.withAlphaComponent(0.3))
} else {
backgroundColor = (incoming ? arguments.presentationData.theme.theme.chat.message.incoming.accentTextColor : arguments.presentationData.theme.theme.chat.message.outgoing.accentTextColor)
textColor = incoming ? arguments.presentationData.theme.theme.chat.message.incoming.accentTextColor : arguments.presentationData.theme.theme.chat.message.outgoing.accentTextColor