mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-25 17:43:18 +00:00
Avoid empty participant list in voice chats
This commit is contained in:
parent
72d0a221cd
commit
0e44390a0f
@ -742,9 +742,9 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
if let initialCall = initialCall, let temporaryParticipantsContext = (self.accountContext.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl)?.impl.syncWith({ impl in
|
if let initialCall = initialCall, let temporaryParticipantsContext = (self.accountContext.cachedGroupCallContexts as? AccountGroupCallContextCacheImpl)?.impl.syncWith({ impl in
|
||||||
impl.get(account: accountContext.account, peerId: peerId, call: CachedChannelData.ActiveCall(id: initialCall.id, accessHash: initialCall.accessHash, title: initialCall.title))
|
impl.get(account: accountContext.account, peerId: peerId, call: CachedChannelData.ActiveCall(id: initialCall.id, accessHash: initialCall.accessHash, title: initialCall.title))
|
||||||
}) {
|
}) {
|
||||||
if let participantsContext = temporaryParticipantsContext.context.participantsContext, let immediateState = participantsContext.immediateState {
|
self.switchToTemporaryParticipantsContext(sourceContext: temporaryParticipantsContext.context.participantsContext, oldMyPeerId: self.joinAsPeerId)
|
||||||
self.switchToTemporaryParticipantsContext(sourceContext: participantsContext, initialState: immediateState, oldMyPeerId: self.joinAsPeerId)
|
} else {
|
||||||
}
|
self.switchToTemporaryParticipantsContext(sourceContext: nil, oldMyPeerId: self.joinAsPeerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.removedChannelMembersDisposable = (accountContext.peerChannelMemberCategoriesContextsManager.removedChannelMembers
|
self.removedChannelMembersDisposable = (accountContext.peerChannelMemberCategoriesContextsManager.removedChannelMembers
|
||||||
@ -817,7 +817,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
self.removedChannelMembersDisposable?.dispose()
|
self.removedChannelMembersDisposable?.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func switchToTemporaryParticipantsContext(sourceContext: GroupCallParticipantsContext, initialState: GroupCallParticipantsContext.State, oldMyPeerId: PeerId) {
|
private func switchToTemporaryParticipantsContext(sourceContext: GroupCallParticipantsContext?, oldMyPeerId: PeerId) {
|
||||||
let myPeerId = self.joinAsPeerId
|
let myPeerId = self.joinAsPeerId
|
||||||
let myPeer = self.accountContext.account.postbox.transaction { transaction -> (Peer, CachedPeerData?)? in
|
let myPeer = self.accountContext.account.postbox.transaction { transaction -> (Peer, CachedPeerData?)? in
|
||||||
if let peer = transaction.getPeer(myPeerId) {
|
if let peer = transaction.getPeer(myPeerId) {
|
||||||
@ -826,6 +826,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let sourceContext = sourceContext, let initialState = sourceContext.immediateState {
|
||||||
let temporaryParticipantsContext = GroupCallParticipantsContext(account: self.account, peerId: self.peerId, myPeerId: myPeerId, id: sourceContext.id, accessHash: sourceContext.accessHash, state: initialState)
|
let temporaryParticipantsContext = GroupCallParticipantsContext(account: self.account, peerId: self.peerId, myPeerId: myPeerId, id: sourceContext.id, accessHash: sourceContext.accessHash, state: initialState)
|
||||||
self.temporaryParticipantsContext = temporaryParticipantsContext
|
self.temporaryParticipantsContext = temporaryParticipantsContext
|
||||||
self.participantsContextStateDisposable.set((combineLatest(queue: .mainQueue(),
|
self.participantsContextStateDisposable.set((combineLatest(queue: .mainQueue(),
|
||||||
@ -922,6 +923,69 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
strongSelf.invitedPeersValue = updatedInvitedPeers
|
strongSelf.invitedPeersValue = updatedInvitedPeers
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
} else {
|
||||||
|
self.temporaryParticipantsContext = nil
|
||||||
|
self.participantsContextStateDisposable.set((myPeer
|
||||||
|
|> deliverOnMainQueue
|
||||||
|
|> take(1)).start(next: { [weak self] myPeerAndCachedData in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var topParticipants: [GroupCallParticipantsContext.Participant] = []
|
||||||
|
|
||||||
|
var members = PresentationGroupCallMembers(
|
||||||
|
participants: [],
|
||||||
|
speakingParticipants: [],
|
||||||
|
totalCount: 0,
|
||||||
|
loadMoreToken: nil
|
||||||
|
)
|
||||||
|
|
||||||
|
var participants: [GroupCallParticipantsContext.Participant] = []
|
||||||
|
|
||||||
|
if !participants.contains(where: { $0.peer.id == myPeerId }) {
|
||||||
|
if let (myPeer, cachedData) = myPeerAndCachedData {
|
||||||
|
let about: String?
|
||||||
|
if let cachedData = cachedData as? CachedUserData {
|
||||||
|
about = cachedData.about
|
||||||
|
} else if let cachedData = cachedData as? CachedUserData {
|
||||||
|
about = cachedData.about
|
||||||
|
} else {
|
||||||
|
about = nil
|
||||||
|
}
|
||||||
|
participants.append(GroupCallParticipantsContext.Participant(
|
||||||
|
peer: myPeer,
|
||||||
|
ssrc: nil,
|
||||||
|
jsonParams: nil,
|
||||||
|
joinTimestamp: strongSelf.temporaryJoinTimestamp,
|
||||||
|
raiseHandRating: nil,
|
||||||
|
hasRaiseHand: false,
|
||||||
|
activityTimestamp: strongSelf.temporaryActivityTimestamp,
|
||||||
|
activityRank: strongSelf.temporaryActivityRank,
|
||||||
|
muteState: GroupCallParticipantsContext.Participant.MuteState(canUnmute: true, mutedByYou: false),
|
||||||
|
volume: nil,
|
||||||
|
about: about
|
||||||
|
))
|
||||||
|
participants.sort()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for participant in participants {
|
||||||
|
members.participants.append(participant)
|
||||||
|
|
||||||
|
if topParticipants.count < 3 {
|
||||||
|
topParticipants.append(participant)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
strongSelf.membersValue = members
|
||||||
|
|
||||||
|
var stateValue = strongSelf.stateValue
|
||||||
|
stateValue.myPeerId = strongSelf.joinAsPeerId
|
||||||
|
|
||||||
|
strongSelf.stateValue = stateValue
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateSessionState(internalState: InternalState, audioSessionControl: ManagedAudioSessionControl?) {
|
private func updateSessionState(internalState: InternalState, audioSessionControl: ManagedAudioSessionControl?) {
|
||||||
@ -1671,7 +1735,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
|||||||
strongSelf.temporaryActivityRank = participant.activityRank
|
strongSelf.temporaryActivityRank = participant.activityRank
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strongSelf.switchToTemporaryParticipantsContext(sourceContext: participantsContext, initialState: immediateState, oldMyPeerId: previousPeerId)
|
strongSelf.switchToTemporaryParticipantsContext(sourceContext: participantsContext, oldMyPeerId: previousPeerId)
|
||||||
} else {
|
} else {
|
||||||
strongSelf.stateValue.myPeerId = peerId
|
strongSelf.stateValue.myPeerId = peerId
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user