Merge branch 'master' into shared-audio-device-module

This commit is contained in:
Ali 2022-11-29 15:23:07 +04:00
commit f90a1bc095
16 changed files with 105 additions and 44 deletions

View File

@ -136,7 +136,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
private let headerContentView = ComponentView<Empty>()
private var primaryContext: ChatListLocationContext?
fileprivate private(set) var primaryContext: ChatListLocationContext?
private let primaryInfoReady = Promise<Bool>()
private var pendingSecondaryContext: ChatListLocationContext?
@ -4744,10 +4744,11 @@ private final class ChatListLocationContext {
self.rightButton = AnyComponentWithIdentity(id: "more", component: AnyComponent(NavigationButtonComponent(
content: .more,
pressed: { [weak parentController] sourceView in
guard let secondaryContext = parentController?.secondaryContext else {
return
if let secondaryContext = parentController?.secondaryContext {
secondaryContext.performMoreAction(sourceView: sourceView)
} else if let primaryContext = parentController?.primaryContext {
primaryContext.performMoreAction(sourceView: sourceView)
}
secondaryContext.performMoreAction(sourceView: sourceView)
},
contextAction: { [weak self] sourceView, gesture in
guard let self, let parentController = self.parentController else {

View File

@ -272,7 +272,7 @@ private final class ChatListShimmerNode: ASDisplayNode {
if !isInlineMode {
if !itemNodes[sampleIndex].avatarNode.isHidden {
context.fillEllipse(in: itemNodes[sampleIndex].avatarNode.frame.offsetBy(dx: 0.0, dy: currentY))
context.fillEllipse(in: itemNodes[sampleIndex].avatarNode.view.convert(itemNodes[sampleIndex].avatarNode.bounds, to: itemNodes[sampleIndex].view).offsetBy(dx: 0.0, dy: currentY))
}
}

View File

@ -921,6 +921,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
private var isHighlighted: Bool = false
private var skipFadeout: Bool = false
private var customAnimationInProgress: Bool = false
private var onlineIsVoiceChat: Bool = false
@ -2463,8 +2464,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
strongSelf.cachedChatListSearchResult = chatListSearchResult
strongSelf.onlineIsVoiceChat = onlineIsVoiceChat
strongSelf.clipsToBounds = true
if let currentHiddenOffset = currentItem?.hiddenOffset, item.hiddenOffset, currentHiddenOffset != item.hiddenOffset {
strongSelf.supernode?.insertSubnode(strongSelf, at: 0)
}
if case .groupReference = item.content {
strongSelf.layer.sublayerTransform = CATransform3DMakeTranslation(0.0, layout.contentSize.height - itemHeight, 0.0)
}
@ -2473,7 +2476,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
strongSelf.separatorNode.backgroundColor = item.presentationData.theme.chatList.itemSeparatorColor
}
let revealOffset = 0.0//strongSelf.revealOffset
let revealOffset = 0.0
let transition: ContainedViewLayoutTransition
if animated {
@ -2482,8 +2485,9 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
transition = .immediate
}
let contextContainerFrame = CGRect(origin: CGPoint(), size: layout.contentSize)
strongSelf.contextContainer.position = contextContainerFrame.center
let contextContainerFrame = CGRect(origin: CGPoint(), size: CGSize(width: layout.contentSize.width, height: itemHeight))
// strongSelf.contextContainer.position = contextContainerFrame.center
transition.updatePosition(node: strongSelf.contextContainer, position: contextContainerFrame.center)
transition.updateBounds(node: strongSelf.contextContainer, bounds: contextContainerFrame.offsetBy(dx: -strongSelf.revealOffset, dy: 0.0))
var mainContentFrame: CGRect
@ -3280,14 +3284,16 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
strongSelf.peerPresenceManager?.reset(presence: EnginePeer.Presence(status: peerPresence.status, lastActivity: 0), isOnline: online)
}
strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)
strongSelf.updateLayout(size: CGSize(width: layout.contentSize.width, height: itemHeight), leftInset: params.leftInset, rightInset: params.rightInset)
if item.editing {
strongSelf.setRevealOptions((left: [], right: []))
} else {
strongSelf.setRevealOptions((left: peerLeftRevealOptions, right: peerRevealOptions))
}
strongSelf.setRevealOptionsOpened(item.hasActiveRevealControls, animated: true)
if !strongSelf.customAnimationInProgress {
strongSelf.setRevealOptionsOpened(item.hasActiveRevealControls, animated: true)
}
strongSelf.view.accessibilityLabel = strongSelf.accessibilityLabel
strongSelf.view.accessibilityValue = strongSelf.accessibilityValue
@ -3648,8 +3654,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
item.interaction.updatePeerGrouping(index.messageIndex.id.peerId, true)
close = false
self.skipFadeout = true
self.customAnimationInProgress = true
self.animateRevealOptionsFill {
self.revealOptionsInteractivelyClosed()
self.customAnimationInProgress = false
}
case RevealOptionKey.unarchive.rawValue:
item.interaction.updatePeerGrouping(index.messageIndex.id.peerId, false)
@ -3665,8 +3673,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
item.interaction.toggleArchivedFolderHiddenByDefault()
close = false
self.skipFadeout = true
self.customAnimationInProgress = true
self.animateRevealOptionsFill {
self.revealOptionsInteractivelyClosed()
self.customAnimationInProgress = false
}
case RevealOptionKey.unhide.rawValue:
item.interaction.toggleArchivedFolderHiddenByDefault()
@ -3677,8 +3687,10 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
}
close = false
self.skipFadeout = true
self.customAnimationInProgress = true
self.animateRevealOptionsFill {
self.revealOptionsInteractivelyClosed()
self.customAnimationInProgress = false
}
default:
break
@ -3703,6 +3715,13 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
item.interaction.setPeerThreadPinned(peerId, threadId, false)
case RevealOptionKey.hide.rawValue:
item.interaction.setPeerThreadHidden(peerId, threadId, true)
close = false
self.skipFadeout = true
self.customAnimationInProgress = true
self.animateRevealOptionsFill {
self.revealOptionsInteractivelyClosed()
self.customAnimationInProgress = false
}
case RevealOptionKey.unhide.rawValue:
item.interaction.setPeerThreadHidden(peerId, threadId, false)
default:

View File

@ -406,6 +406,9 @@ func chatListNodeEntriesForView(_ view: EngineChatList, state: ChatListNodeState
if !view.hasLater && savedMessagesPeer == nil {
pinnedIndexOffset += UInt16(filteredAdditionalItemEntries.count)
}
var hiddenGeneralThread: ChatListNodeEntry?
loop: for entry in view.items {
var peerId: EnginePeer.Id?
var threadId: Int64?
@ -458,7 +461,7 @@ func chatListNodeEntriesForView(_ view: EngineChatList, state: ChatListNodeState
threadInfo = ChatListItemContent.ThreadInfo(id: threadId, info: threadData.info, isOwnedByMe: threadData.isOwnedByMe, isClosed: threadData.isClosed, isHidden: threadData.isHidden)
}
result.append(.PeerEntry(ChatListNodeEntry.PeerEntryData(
let entry: ChatListNodeEntry = .PeerEntry(ChatListNodeEntry.PeerEntryData(
index: offsetPinnedIndex(entry.index, offset: pinnedIndexOffset),
presentationData: state.presentationData,
messages: updatedMessages,
@ -481,8 +484,19 @@ func chatListNodeEntriesForView(_ view: EngineChatList, state: ChatListNodeState
forumTopicData: entry.forumTopicData,
topForumTopicItems: entry.topForumTopicItems,
revealed: threadId == 1 && (state.hiddenItemShouldBeTemporaryRevealed || state.editing)
)))
))
if let threadInfo, threadInfo.isHidden {
hiddenGeneralThread = entry
} else {
result.append(entry)
}
}
if let hiddenGeneralThread {
result.append(hiddenGeneralThread)
}
if !view.hasLater {
var pinningIndex: UInt16 = UInt16(pinnedIndexOffset == 0 ? 0 : (pinnedIndexOffset - 1))

View File

@ -496,7 +496,7 @@ open class ItemListRevealOptionsItemNode: ListViewItemNode, UIGestureRecognizerD
open func animateRevealOptionsFill(completion: (() -> Void)? = nil) {
if let validLayout = self.validLayout {
self.layer.allowsGroupOpacity = true
self.updateRevealOffsetInternal(offset: -validLayout.0.width - 74.0, transition: .animated(duration: 0.2, curve: .spring), completion: {
self.updateRevealOffsetInternal(offset: -validLayout.0.width - 74.0, transition: .animated(duration: 0.3, curve: .spring), completion: {
self.layer.allowsGroupOpacity = false
completion?()
})

View File

@ -351,7 +351,7 @@ private func channelAdminsControllerEntries(presentationData: PresentationData,
}
entries.append(.recentActions(presentationData.theme, presentationData.strings.Group_Info_AdminLog))
if isGroup && peer.hasPermission(.deleteAllMessages) && antiSpamAvailable {
if isGroup && peer.hasPermission(.deleteAllMessages) && (antiSpamAvailable || antiSpamEnabled) {
entries.append(.antiSpam(presentationData.theme, presentationData.strings.Group_Management_AntiSpam, antiSpamEnabled))
entries.append(.antiSpamInfo(presentationData.theme, presentationData.strings.Group_Management_AntiSpamInfo))
}

View File

@ -193,7 +193,7 @@ func _internal_createForumChannelTopic(account: Account, peerId: PeerId, title:
}
|> castError(CreateForumChannelTopicError.self)
|> mapToSignal { peer -> Signal<Int64, CreateForumChannelTopicError> in
guard let peer else {
guard let peer = peer else {
return .fail(.generic)
}
guard let inputChannel = apiInputChannel(peer) else {

View File

@ -3574,7 +3574,8 @@ func replayFinalState(
updatedIncomingThreadReadStates[threadMessageId] = readMaxId
}
if let channel = transaction.getPeer(threadMessageId.peerId) as? TelegramChannel, case .group = channel.info, channel.flags.contains(.isForum) {
if var data = transaction.getMessageHistoryThreadInfo(peerId: threadMessageId.peerId, threadId: Int64(threadMessageId.id))?.data.get(MessageHistoryThreadData.self) {
let threadId = Int64(threadMessageId.id)
if var data = transaction.getMessageHistoryThreadInfo(peerId: threadMessageId.peerId, threadId: threadId)?.data.get(MessageHistoryThreadData.self) {
if readMaxId > data.maxIncomingReadId {
if let toIndex = transaction.getMessage(MessageId(peerId: threadMessageId.peerId, namespace: threadMessageId.namespace, id: readMaxId))?.index {
if let count = transaction.getThreadMessageCount(peerId: threadMessageId.peerId, threadId: Int64(threadMessageId.id), namespace: threadMessageId.namespace, fromIdExclusive: data.maxIncomingReadId, toIndex: toIndex) {
@ -3582,6 +3583,16 @@ func replayFinalState(
}
}
if let topMessageIndex = transaction.getMessageHistoryThreadTopMessage(peerId: threadMessageId.peerId, threadId: threadId, namespaces: Set([Namespaces.Message.Cloud])) {
if readMaxId >= topMessageIndex.id.id {
let containingHole = transaction.getThreadIndexHole(peerId: threadMessageId.peerId, threadId: threadId, namespace: topMessageIndex.id.namespace, containing: topMessageIndex.id.id)
if let _ = containingHole[.everywhere] {
} else {
data.incomingUnreadCount = 0
}
}
}
data.maxKnownMessageId = max(data.maxKnownMessageId, readMaxId)
data.maxIncomingReadId = max(data.maxIncomingReadId, readMaxId)
@ -4069,14 +4080,18 @@ func replayFinalState(
}
})
}
case let .UpdateAutoremoveTimeout(peer, value):
transaction.updatePeerCachedData(peerIds: Set([peer.peerId]), update: { _, current in
if let current = current as? CachedUserData {
return current.withUpdatedAutoremoveTimeout(.known(value))
} else if let current = current as? CachedGroupData {
return current.withUpdatedAutoremoveTimeout(.known(value))
} else if let current = current as? CachedChannelData {
return current.withUpdatedAutoremoveTimeout(.known(value))
case let .UpdateAutoremoveTimeout(peer, autoremoveValue):
let peerId = peer.peerId
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
if peerId.namespace == Namespaces.Peer.CloudUser {
let current = (current as? CachedUserData) ?? CachedUserData()
return current.withUpdatedAutoremoveTimeout(.known(autoremoveValue))
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
let current = (current as? CachedChannelData) ?? CachedChannelData()
return current.withUpdatedAutoremoveTimeout(.known(autoremoveValue))
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
let current = (current as? CachedGroupData) ?? CachedGroupData()
return current.withUpdatedAutoremoveTimeout(.known(autoremoveValue))
} else {
return current
}

View File

@ -295,7 +295,7 @@ func fetchMessageHistoryHole(accountPeerId: PeerId, source: FetchMessageHistoryH
}
}
|> mapToSignal { (peer, hash) -> Signal<FetchMessageHistoryHoleResult?, NoError> in
guard let peer else {
guard let peer = peer else {
return .single(FetchMessageHistoryHoleResult(removedIndices: IndexSet(), strictRemovedIndices: IndexSet(), actualPeerId: nil, actualThreadId: nil, ids: []))
}
guard let inputPeer = forceApiInputPeer(peer) else {
@ -820,11 +820,14 @@ func fetchChatListHole(postbox: Postbox, network: Network, accountPeerId: PeerId
for (peerId, autoremoveValue) in fetchedChats.ttlPeriods {
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
if let current = current as? CachedUserData {
if peerId.namespace == Namespaces.Peer.CloudUser {
let current = (current as? CachedUserData) ?? CachedUserData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else if let current = current as? CachedGroupData {
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
let current = (current as? CachedChannelData) ?? CachedChannelData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else if let current = current as? CachedChannelData {
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
let current = (current as? CachedGroupData) ?? CachedGroupData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else {
return current

View File

@ -236,11 +236,14 @@ private func synchronizePinnedChats(transaction: Transaction, postbox: Postbox,
for (peerId, autoremoveValue) in ttlPeriods {
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
if let current = current as? CachedUserData {
if peerId.namespace == Namespaces.Peer.CloudUser {
let current = (current as? CachedUserData) ?? CachedUserData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else if let current = current as? CachedGroupData {
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
let current = (current as? CachedChannelData) ?? CachedChannelData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else if let current = current as? CachedChannelData {
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
let current = (current as? CachedGroupData) ?? CachedGroupData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else {
return current

View File

@ -190,11 +190,14 @@ func _internal_setChatMessageAutoremoveTimeoutInteractively(account: Account, pe
updatedTimeout = .known(nil)
}
if let current = current as? CachedUserData {
if peerId.namespace == Namespaces.Peer.CloudUser {
let current = (current as? CachedUserData) ?? CachedUserData()
return current.withUpdatedAutoremoveTimeout(updatedTimeout)
} else if let current = current as? CachedGroupData {
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
let current = (current as? CachedChannelData) ?? CachedChannelData()
return current.withUpdatedAutoremoveTimeout(updatedTimeout)
} else if let current = current as? CachedChannelData {
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
let current = (current as? CachedGroupData) ?? CachedGroupData()
return current.withUpdatedAutoremoveTimeout(updatedTimeout)
} else {
return current

View File

@ -143,7 +143,7 @@ private class ReplyThreadHistoryContextImpl {
}
|> castError(FetchChannelReplyThreadMessageError.self)
|> mapToSignal { peer -> Signal<DiscussionMessage, FetchChannelReplyThreadMessageError> in
guard let peer else {
guard let peer = peer else {
return .fail(.generic)
}
guard let inputPeer = apiInputPeer(peer) else {
@ -613,7 +613,7 @@ func _internal_fetchChannelReplyThreadMessage(account: Account, messageId: Messa
}
|> castError(FetchChannelReplyThreadMessageError.self)
|> mapToSignal { peer -> Signal<ChatReplyThreadMessage, FetchChannelReplyThreadMessageError> in
guard let peer else {
guard let peer = peer else {
return .fail(.generic)
}
guard let inputPeer = apiInputPeer(peer) else {

View File

@ -807,7 +807,7 @@ public final class SparseMessageCalendar {
return transaction.getPeer(peerId)
}
|> mapToSignal { peer -> Signal<LoadResult, NoError> in
guard let peer else {
guard let peer = peer else {
return .single(LoadResult(messagesByDay: [:], nextOffset: nil, minMessageId: nil, minTimestamp: nil))
}
guard let inputPeer = apiInputPeer(peer) else {

View File

@ -769,11 +769,14 @@ private func loadAndStorePeerChatInfos(accountPeerId: PeerId, postbox: Postbox,
for (peerId, autoremoveValue) in ttlPeriods {
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, current in
if let current = current as? CachedUserData {
if peerId.namespace == Namespaces.Peer.CloudUser {
let current = (current as? CachedUserData) ?? CachedUserData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else if let current = current as? CachedGroupData {
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
let current = (current as? CachedChannelData) ?? CachedChannelData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else if let current = current as? CachedChannelData {
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
let current = (current as? CachedGroupData) ?? CachedGroupData()
return current.withUpdatedAutoremoveTimeout(autoremoveValue)
} else {
return current

View File

@ -1963,7 +1963,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
}
var hasReply = replyMessage != nil
if !isInstantVideo, let replyMessage = replyMessage, replyMessage.threadId != nil, case let .peer(peerId) = item.chatLocation, peerId == replyMessage.id.peerId, let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum) {
if !isInstantVideo, let replyMessage = replyMessage, replyMessage.threadId != nil, case let .peer(peerId) = item.chatLocation, peerId == replyMessage.id.peerId, let channel = item.message.peers[item.message.id.peerId] as? TelegramChannel, channel.flags.contains(.isForum), item.message.associatedThreadInfo != nil {
if let threadId = item.message.threadId, Int64(replyMessage.id.id) == threadId {
hasReply = false
}

View File

@ -302,7 +302,7 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode {
self.validLayout = (size, inset, interfaceState)
let bounds = CGRect(origin: CGPoint(), size: CGSize(width: size.width, height: 45.0))
let leftInset: CGFloat = 55.0
let leftInset: CGFloat = 55.0 + inset
let textLineInset: CGFloat = 10.0
let rightInset: CGFloat = 55.0
let textRightInset: CGFloat = 20.0