From 93ec856482c268265cc39d4cb05be6d0386028c0 Mon Sep 17 00:00:00 2001 From: overtake Date: Fri, 6 Nov 2020 12:35:47 +0400 Subject: [PATCH 1/6] fixed pinned chats --- submodules/TelegramCore/Sources/Holes.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/TelegramCore/Sources/Holes.swift b/submodules/TelegramCore/Sources/Holes.swift index beca7c99ba..22b6be9ed8 100644 --- a/submodules/TelegramCore/Sources/Holes.swift +++ b/submodules/TelegramCore/Sources/Holes.swift @@ -614,7 +614,7 @@ func fetchChatListHole(postbox: Postbox, network: Network, accountPeerId: PeerId for peerId in fetchedChats.chatPeerIds { if let peer = transaction.getPeer(peerId) { - transaction.updatePeerChatListInclusion(peerId, inclusion: .ifHasMessagesOrOneOf(groupId: groupId, pinningIndex: nil, minTimestamp: minTimestampForPeerInclusion(peer))) + transaction.updatePeerChatListInclusion(peerId, inclusion: .ifHasMessagesOrOneOf(groupId: groupId, pinningIndex: transaction.getPeerChatListIndex(peerId)?.1.pinningIndex, minTimestamp: minTimestampForPeerInclusion(peer))) } else { assertionFailure() } From fb500a1345c0412978fa0ab4ceee86eb95dc91ca Mon Sep 17 00:00:00 2001 From: overtake Date: Wed, 25 Nov 2020 15:31:28 +0400 Subject: [PATCH 2/6] [skip ci] --- .../Public/FFMpegBinding/FFMpegBinding.h | 2 +- .../Postbox/Sources/MessageHistoryView.swift | 32 +++++++++++-------- submodules/TgVoipWebrtc/tgcalls | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegBinding.h b/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegBinding.h index 565c6c170a..f6ae7d835e 100644 --- a/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegBinding.h +++ b/submodules/FFMpegBinding/Public/FFMpegBinding/FFMpegBinding.h @@ -1,4 +1,4 @@ -#import +#import #import #import diff --git a/submodules/Postbox/Sources/MessageHistoryView.swift b/submodules/Postbox/Sources/MessageHistoryView.swift index 1753b2764b..71b6869b36 100644 --- a/submodules/Postbox/Sources/MessageHistoryView.swift +++ b/submodules/Postbox/Sources/MessageHistoryView.swift @@ -667,8 +667,12 @@ final class MutableMessageHistoryView { var updatedCachedPeerDataMessages = false var currentCachedPeerData: CachedPeerData? - for i in 0 ..< self.additionalDatas.count { - switch self.additionalDatas[i] { + + let additionalDatas = self.additionalDatas + var updated = self.additionalDatas + + for i in 0 ..< additionalDatas.count { + switch additionalDatas[i] { case let .cachedPeerData(peerId, currentData): currentCachedPeerData = currentData if let updatedData = transaction.currentUpdatedCachedPeerData[peerId] { @@ -676,7 +680,7 @@ final class MutableMessageHistoryView { updatedCachedPeerDataMessages = true } currentCachedPeerData = updatedData - self.additionalDatas[i] = .cachedPeerData(peerId, updatedData) + updated[i] = .cachedPeerData(peerId, updatedData) hasChanges = true } case .cachedPeerDataMessages: @@ -729,13 +733,13 @@ final class MutableMessageHistoryView { } if updateMessage { let messages = postbox.getMessageGroup(at: id) ?? [] - self.additionalDatas[i] = .message(id, messages) + updated[i] = .message(id, messages) hasChanges = true } } case let .peerChatState(peerId, _): if transaction.currentUpdatedPeerChatStates.contains(peerId) { - self.additionalDatas[i] = .peerChatState(peerId, postbox.peerChatStateTable.get(peerId) as? PeerChatState) + updated[i] = .peerChatState(peerId, postbox.peerChatStateTable.get(peerId) as? PeerChatState) hasChanges = true } case .totalUnreadState: @@ -744,7 +748,7 @@ final class MutableMessageHistoryView { break case let .cacheEntry(entryId, _): if transaction.updatedCacheEntryKeys.contains(entryId) { - self.additionalDatas[i] = .cacheEntry(entryId, postbox.retrieveItemCacheEntry(id: entryId)) + updated[i] = .cacheEntry(entryId, postbox.retrieveItemCacheEntry(id: entryId)) hasChanges = true } case .preferencesEntry: @@ -759,20 +763,20 @@ final class MutableMessageHistoryView { } if value != updatedValue { - self.additionalDatas[i] = .peerIsContact(peerId, value) + updated[i] = .peerIsContact(peerId, value) hasChanges = true } } case let .peer(peerId, _): if let peer = transaction.currentUpdatedPeers[peerId] { - self.additionalDatas[i] = .peer(peerId, peer) + updated[i] = .peer(peerId, peer) hasChanges = true } } } if let cachedData = currentCachedPeerData, !cachedData.messageIds.isEmpty { - for i in 0 ..< self.additionalDatas.count { - switch self.additionalDatas[i] { + for i in 0 ..< additionalDatas.count { + switch additionalDatas[i] { case .cachedPeerDataMessages(_, _): outer: for operationSet in operations { for operation in operationSet { @@ -802,8 +806,8 @@ final class MutableMessageHistoryView { if updatedCachedPeerDataMessages { hasChanges = true - for i in 0 ..< self.additionalDatas.count { - switch self.additionalDatas[i] { + for i in 0 ..< additionalDatas.count { + switch additionalDatas[i] { case let .cachedPeerDataMessages(peerId, _): var messages: [MessageId: Message] = [:] if let cachedData = currentCachedPeerData { @@ -813,13 +817,15 @@ final class MutableMessageHistoryView { } } } - self.additionalDatas[i] = .cachedPeerDataMessages(peerId, messages) + updated[i] = .cachedPeerDataMessages(peerId, messages) default: break } } } + self.additionalDatas = updated + if !transaction.currentPeerHoleOperations.isEmpty { var holePeerIdsSet: [PeerId] = [] switch self.peerIds { diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index b245c575f3..64f96a1b4f 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit b245c575f350e13186d34b9ae38f6af555c6fe14 +Subproject commit 64f96a1b4fcfb8afdb0fb7749082cb42cdad7901 From d71a74af154c53502bc775d9b14c674db3696855 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 25 Nov 2020 15:37:44 +0400 Subject: [PATCH 3/6] Voice Chat UI fixes --- .../AccountContext/Sources/PresentationCallManager.swift | 2 ++ .../TelegramCallsUI/Sources/PresentationGroupCall.swift | 8 ++++++++ .../TelegramCallsUI/Sources/VoiceChatActionButton.swift | 7 +++---- .../TelegramCallsUI/Sources/VoiceChatController.swift | 8 +++++++- .../Sources/VoiceChatParticipantItem.swift | 4 ++-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index a3e544a066..15d556e73e 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -206,6 +206,8 @@ public protocol PresentationGroupCall: class { func toggleIsMuted() func setIsMuted(_ value: Bool) func setCurrentAudioOutput(_ output: AudioSessionOutput) + + func invitePeer(_ peerId: PeerId) } public protocol PresentationCallManager: class { diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index cc9212a9cb..d4dd35fa46 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -552,4 +552,12 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { strongSelf.updateSessionState(internalState: .active(value), audioSessionControl: strongSelf.audioSessionControl) })) } + + public func invitePeer(_ peerId: PeerId) { + guard case let .estabilished(callInfo, _, _, _, _) = self.internalState else { + return + } + + let _ = inviteToGroupCall(account: self.account, callId: callInfo.id, accessHash: callInfo.accessHash, peerId: peerId).start() + } } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift b/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift index af8f5ec34d..a5766e7e78 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift @@ -88,11 +88,11 @@ private final class Blob { } } - var currentShape: CGPath? + var currentShape: UIBezierPath? private var transition: CGFloat = 0 { didSet { if let currentPoints = self.currentPoints { - self.currentShape = UIBezierPath.smoothCurve(through: currentPoints, length: size.width, smoothness: smoothness).cgPath + self.currentShape = UIBezierPath.smoothCurve(through: currentPoints, length: size.width, smoothness: smoothness) } } } @@ -450,7 +450,6 @@ private class VoiceChatActionButtonBackgroundNode: ASDisplayNode { let buttonSize = CGSize(width: 144.0, height: 144.0) let radius = buttonSize.width / 2.0 - let blue = UIColor(rgb: 0x0078ff) let lightBlue = UIColor(rgb: 0x59c7f8) let green = UIColor(rgb: 0x33c659) @@ -512,7 +511,7 @@ private class VoiceChatActionButtonBackgroundNode: ASDisplayNode { if let blobsState = parameters.state as? VoiceChatActionButtonBackgroundNodeBlobState { for blob in blobsState.blobs { if let path = blob.currentShape { - let uiPath = UIBezierPath(cgPath: path) + let uiPath = path let toOrigin = CGAffineTransform(translationX: -bounds.size.width / 2.0, y: -bounds.size.height / 2.0) let fromOrigin = CGAffineTransform(translationX: bounds.size.width / 2.0, y: bounds.size.height / 2.0) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index c7325cb324..9d95ee805f 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -273,6 +273,8 @@ public final class VoiceChatController: ViewController { ), in: .current ) + + strongSelf.call.invitePeer(peer.id) }, peerContextAction: { [weak self] peer, sourceNode, gesture in guard let strongSelf = self, let controller = strongSelf.controller, let sourceNode = sourceNode as? ContextExtractedContentContainingNode else { return @@ -639,6 +641,7 @@ public final class VoiceChatController: ViewController { let actionButtonTitle: String let actionButtonSubtitle: String let audioButtonAppearance: CallControllerButtonItemNode.Content.Appearance + var actionButtonEnabled = true if let callState = callState { isMicOn = !callState.isMuted @@ -648,6 +651,7 @@ public final class VoiceChatController: ViewController { actionButtonTitle = self.presentationData.strings.VoiceChat_Connecting actionButtonSubtitle = "" audioButtonAppearance = .color(.custom(0x1c1c1e)) + actionButtonEnabled = false case .connected: actionButtonState = .active(state: isMicOn ? .on : .muted) if isMicOn { @@ -665,8 +669,10 @@ public final class VoiceChatController: ViewController { actionButtonTitle = self.presentationData.strings.VoiceChat_Connecting actionButtonSubtitle = "" audioButtonAppearance = .color(.custom(0x1c1c1e)) + actionButtonEnabled = false } + self.actionButton.isUserInteractionEnabled = actionButtonEnabled self.actionButton.update(size: centralButtonSize, buttonSize: CGSize(width: 144.0, height: 144.0), state: actionButtonState, title: actionButtonTitle, subtitle: actionButtonSubtitle, animated: true) transition.updateFrame(node: self.actionButton, frame: actionButtonFrame) @@ -703,7 +709,7 @@ public final class VoiceChatController: ViewController { soundImage = .speaker case .speaker: soundImage = .speaker -// soundAppearance = .blurred(isFilled: false) + soundAppearance = .blurred(isFilled: true) case .headphones: soundImage = .bluetooth case let .bluetooth(type): diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift index f89f08cc08..ef8167540f 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift @@ -345,8 +345,8 @@ public class VoiceChatParticipantItemNode: ListViewItemNode { let verticalOffset: CGFloat = 0.0 let avatarSize: CGFloat = 40.0 - let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 12.0 - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) - let (statusLayout, statusApply) = makeStatusLayout(TextNodeLayoutArguments(attributedString: statusAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 8.0 - rightInset, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 12.0 - rightInset - 25.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + let (statusLayout, statusApply) = makeStatusLayout(TextNodeLayoutArguments(attributedString: statusAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - 8.0 - rightInset - 25.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) let insets = UIEdgeInsets() From adabba67cbb1b555c6a0d6ce16b1d3db017731d5 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 25 Nov 2020 15:41:08 +0400 Subject: [PATCH 4/6] Fix typo --- submodules/SyncCore/Sources/TelegramMediaAction.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/SyncCore/Sources/TelegramMediaAction.swift b/submodules/SyncCore/Sources/TelegramMediaAction.swift index 517f672dbd..ee07f97508 100644 --- a/submodules/SyncCore/Sources/TelegramMediaAction.swift +++ b/submodules/SyncCore/Sources/TelegramMediaAction.swift @@ -207,7 +207,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { encoder.encodeInt32(23, forKey: "_rawValue") encoder.encodeInt64(callId, forKey: "callId") encoder.encodeInt64(accessHash, forKey: "accessHash") - encoder.encodeInt64(peerId.toInt64(), forKey: "peerIdId") + encoder.encodeInt64(peerId.toInt64(), forKey: "peerId") } } From 51bf00ad4a0942b532175481cb10bedca297ad43 Mon Sep 17 00:00:00 2001 From: overtake Date: Wed, 25 Nov 2020 15:54:44 +0400 Subject: [PATCH 5/6] [skip ci] --- submodules/TgVoipWebrtc/tgcalls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index 64f96a1b4f..aeaa63b502 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit 64f96a1b4fcfb8afdb0fb7749082cb42cdad7901 +Subproject commit aeaa63b502a1ee88feef282af739980001138993 From 82ff76bb694e994f668a8c371f14167408246063 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 25 Nov 2020 18:09:43 +0400 Subject: [PATCH 6/6] Fix peer presences in voice chat --- submodules/TelegramCallsUI/Sources/VoiceChatController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index f751fd4ed9..d209be43b7 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -966,6 +966,7 @@ public final class VoiceChatController: ViewController { entries.append(PeerEntry( peer: member.peer, + presence: member.presences[member.peer.id] as? TelegramUserPresence, activityTimestamp: Int32.max - 1 - index, state: memberState, muteState: memberMuteState,