From 0e33b28656165b12f0f87facc15b224fcf4ecac7 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 12 Mar 2021 22:04:22 +0400 Subject: [PATCH 1/2] Fix memory leak --- .../TelegramCallsUI/Sources/VoiceChatController.swift | 11 ++++++----- .../Sources/VoiceChatParticipantItem.swift | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index 12f2b26097..58e49e5e2b 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -1082,11 +1082,12 @@ public final class VoiceChatController: ViewController { guard let strongSelf = self else { return } + let callPeerId = strongSelf.call.peerId let _ = (strongSelf.context.account.postbox.transaction { transaction -> String? in - if let peer = transaction.getPeer(call.peerId), let addressName = peer.addressName, !addressName.isEmpty { + if let peer = transaction.getPeer(callPeerId), let addressName = peer.addressName, !addressName.isEmpty { return "https://t.me/\(addressName)" - } else if let cachedData = transaction.getPeerCachedData(peerId: call.peerId) { + } else if let cachedData = transaction.getPeerCachedData(peerId: callPeerId) { if let cachedData = cachedData as? CachedChannelData { return cachedData.exportedInvitation?.link } else if let cachedData = cachedData as? CachedGroupData { @@ -1452,7 +1453,7 @@ public final class VoiceChatController: ViewController { } }) - self.audioOutputStateDisposable = (call.audioOutputState + self.audioOutputStateDisposable = (self.call.audioOutputState |> deliverOnMainQueue).start(next: { [weak self] state in guard let strongSelf = self else { return @@ -1467,7 +1468,7 @@ public final class VoiceChatController: ViewController { } }) - self.audioLevelsDisposable = (call.audioLevels + self.audioLevelsDisposable = (self.call.audioLevels |> deliverOnMainQueue).start(next: { [weak self] levels in guard let strongSelf = self else { return @@ -1501,7 +1502,7 @@ public final class VoiceChatController: ViewController { strongSelf.itemInteraction?.updateAudioLevels(levels) }) - self.myAudioLevelDisposable = (call.myAudioLevel + self.myAudioLevelDisposable = (self.call.myAudioLevel |> deliverOnMainQueue).start(next: { [weak self] level in guard let strongSelf = self else { return diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift index d5f43bd2ab..2c3fe2daef 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatParticipantItem.swift @@ -726,7 +726,7 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode { raiseHandNode.playRandomAnimation() strongSelf.raiseHandTimer = SwiftSignalKit.Timer(timeout: Double.random(in: 8.0 ... 10.5), repeat: true, completion: { - strongSelf.raiseHandNode?.playRandomAnimation() + self?.raiseHandNode?.playRandomAnimation() }, queue: Queue.mainQueue()) strongSelf.raiseHandTimer?.start() } From 248e8f7f12cce4eb019db39152fefbf6022f8ffd Mon Sep 17 00:00:00 2001 From: Ali <> Date: Sat, 13 Mar 2021 00:14:36 +0400 Subject: [PATCH 2/2] Fix channel updates --- .../Sources/AccountStateManagementUtils.swift | 12 +++++++----- submodules/TelegramCore/Sources/GroupCalls.swift | 13 ++++++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift index 8c5d288be0..bf4ddea375 100644 --- a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift @@ -50,7 +50,7 @@ private func activeChannelsFromUpdateGroups(_ groups: [UpdateGroup]) -> Set Set { @@ -110,13 +110,15 @@ private func peerIdsRequiringLocalChatStateFromUpdateGroups(_ groups: [UpdateGro for group in groups { peerIds.formUnion(peerIdsRequiringLocalChatStateFromUpdates(group.updates)) - for chat in group.chats { + /*for chat in group.chats { if let channel = parseTelegramGroupOrChannel(chat: chat) as? TelegramChannel { - if case .member = channel.participationStatus { - peerIds.insert(channel.id) + if let accessHash = channel.accessHash, case .personal = accessHash { + if case .member = channel.participationStatus { + peerIds.insert(channel.id) + } } } - } + }*/ switch group { case let .ensurePeerHasLocalState(peerId): diff --git a/submodules/TelegramCore/Sources/GroupCalls.swift b/submodules/TelegramCore/Sources/GroupCalls.swift index 2cc052c967..427ca4b413 100644 --- a/submodules/TelegramCore/Sources/GroupCalls.swift +++ b/submodules/TelegramCore/Sources/GroupCalls.swift @@ -828,6 +828,7 @@ public final class GroupCallParticipantsContext { public var participationStatusChange: ParticipationStatusChange public var volume: Int32? public var about: String? + public var isMin: Bool init( peerId: PeerId, @@ -839,7 +840,8 @@ public final class GroupCallParticipantsContext { muteState: Participant.MuteState?, participationStatusChange: ParticipationStatusChange, volume: Int32?, - about: String? + about: String?, + isMin: Bool ) { self.peerId = peerId self.ssrc = ssrc @@ -851,6 +853,7 @@ public final class GroupCallParticipantsContext { self.participationStatusChange = participationStatusChange self.volume = volume self.about = about + self.isMin = isMin } } @@ -1586,6 +1589,7 @@ extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate { } let isRemoved = (flags & (1 << 1)) != 0 let justJoined = (flags & (1 << 4)) != 0 + let isMin = (flags & (1 << 8)) != 0 let participationStatusChange: GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate.ParticipationStatusChange if isRemoved { @@ -1614,7 +1618,8 @@ extension GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate { muteState: muteState, participationStatusChange: participationStatusChange, volume: volume, - about: about + about: about, + isMin: isMin ) } } @@ -1647,6 +1652,7 @@ extension GroupCallParticipantsContext.Update.StateUpdate { } let isRemoved = (flags & (1 << 1)) != 0 let justJoined = (flags & (1 << 4)) != 0 + let isMin = (flags & (1 << 8)) != 0 let participationStatusChange: GroupCallParticipantsContext.Update.StateUpdate.ParticipantUpdate.ParticipationStatusChange if isRemoved { @@ -1675,7 +1681,8 @@ extension GroupCallParticipantsContext.Update.StateUpdate { muteState: muteState, participationStatusChange: participationStatusChange, volume: volume, - about: about + about: about, + isMin: isMin )) } }