From 1e0a7559aa524aa6f423191c0a8cc4ec097cab36 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Fri, 12 Mar 2021 17:52:45 +0400 Subject: [PATCH] Subscribe to channel updates while in voice chat --- .../Sources/PresentationGroupCall.swift | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift index d0f9461669..10a833b9ba 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationGroupCall.swift @@ -530,6 +530,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { private var processedMissingSsrcs = Set() private let missingSsrcsDisposable = MetaDisposable() private var isRequestingMissingSsrcs: Bool = false + + private var peerUpdatesSubscription: Disposable? init( accountContext: AccountContext, @@ -761,6 +763,9 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { let _ = (self.account.postbox.loadedPeerWithId(peerId) |> deliverOnMainQueue).start(next: { [weak self] peer in + guard let strongSelf = self else { + return + } var canManageCall = false if let peer = peer as? TelegramGroup { if case .creator = peer.role { @@ -774,14 +779,12 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { } else if (peer.adminRights?.rights.contains(.canManageCalls) == true) { canManageCall = true } + strongSelf.peerUpdatesSubscription = strongSelf.accountContext.account.viewTracker.polledChannel(peerId: peer.id).start() } - if let strongSelf = self { - var updatedValue = strongSelf.stateValue - updatedValue.canManageCall = canManageCall - strongSelf.stateValue = updatedValue - } + var updatedValue = strongSelf.stateValue + updatedValue.canManageCall = canManageCall + strongSelf.stateValue = updatedValue }) - self.requestCall(movingFromBroadcastToRtc: false) } @@ -815,6 +818,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall { self.audioOutputStateDisposable?.dispose() self.removedChannelMembersDisposable?.dispose() + + self.peerUpdatesSubscription?.dispose() } private func switchToTemporaryParticipantsContext(sourceContext: GroupCallParticipantsContext?, oldMyPeerId: PeerId) {