This commit is contained in:
Ali
2021-03-12 19:11:30 +04:00
parent 6539d0dfe0
commit dbaef794d4
2 changed files with 13 additions and 8 deletions

View File

@@ -1309,10 +1309,12 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
return rawAdminIds
}
|> distinctUntilChanged
let myPeerId = self.joinAsPeerId
var initialState = initialState
if let participantsContext = self.participantsContext, let immediateState = participantsContext.immediateState {
initialState.mergeActivity(from: immediateState)
initialState.mergeActivity(from: immediateState, myPeerId: myPeerId, previousMyPeerId: self.ignorePreviousJoinAsPeerId?.0)
}
let participantsContext = GroupCallParticipantsContext(
@@ -1325,7 +1327,6 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
)
self.temporaryParticipantsContext = nil
self.participantsContext = participantsContext
let myPeerId = self.joinAsPeerId
let myPeer = self.accountContext.account.postbox.transaction { transaction -> (Peer, CachedPeerData?)? in
if let peer = transaction.getPeer(myPeerId) {
return (peer, transaction.getPeerCachedData(peerId: myPeerId))

View File

@@ -452,7 +452,7 @@ public func joinGroupCall(account: Account, peerId: PeerId, joinAs: PeerId?, cal
return .fail(.generic)
}
var apiUsers: [Api.User] = []
let apiUsers: [Api.User] = []
state.adminIds = Set(peerAdminIds)
@@ -755,7 +755,7 @@ public final class GroupCallParticipantsContext {
public var totalCount: Int
public var version: Int32
public mutating func mergeActivity(from other: State) {
public mutating func mergeActivity(from other: State, myPeerId: PeerId, previousMyPeerId: PeerId?) {
var indexMap: [PeerId: Int] = [:]
for i in 0 ..< other.participants.count {
indexMap[other.participants[i].peer.id] = i
@@ -764,6 +764,9 @@ public final class GroupCallParticipantsContext {
for i in 0 ..< self.participants.count {
if let index = indexMap[self.participants[i].peer.id] {
self.participants[i].mergeActivity(from: other.participants[index])
if self.participants[i].peer.id == myPeerId || self.participants[i].peer.id == previousMyPeerId {
self.participants[i].joinTimestamp = other.participants[index].joinTimestamp
}
}
}
@@ -1292,9 +1295,11 @@ public final class GroupCallParticipantsContext {
assertionFailure()
continue
}
var previousJoinTimestamp: Int32?
var previousActivityTimestamp: Double?
var previousActivityRank: Int?
if let index = updatedParticipants.firstIndex(where: { $0.peer.id == participantUpdate.peerId }) {
previousJoinTimestamp = updatedParticipants[index].joinTimestamp
previousActivityTimestamp = updatedParticipants[index].activityTimestamp
previousActivityRank = updatedParticipants[index].activityRank
updatedParticipants.remove(at: index)
@@ -1302,7 +1307,7 @@ public final class GroupCallParticipantsContext {
updatedTotalCount += 1
strongSelf.memberEventsPipe.putNext(MemberEvent(peerId: participantUpdate.peerId, joined: true))
}
var activityTimestamp: Double?
if let previousActivityTimestamp = previousActivityTimestamp, let updatedActivityTimestamp = participantUpdate.activityTimestamp {
activityTimestamp = max(updatedActivityTimestamp, previousActivityTimestamp)
@@ -1314,7 +1319,7 @@ public final class GroupCallParticipantsContext {
peer: peer,
ssrc: participantUpdate.ssrc,
jsonParams: participantUpdate.jsonParams,
joinTimestamp: participantUpdate.joinTimestamp,
joinTimestamp: previousJoinTimestamp ?? participantUpdate.joinTimestamp,
raiseHandRating: participantUpdate.raiseHandRating,
hasRaiseHand: participantUpdate.raiseHandRating != nil,
activityTimestamp: activityTimestamp,
@@ -1773,9 +1778,8 @@ public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox,
return network.request(Api.functions.phone.getGroupCallJoinAs(peer: inputPeer))
|> retryRequest
|> mapToSignal { result in
var peers:[Peer]
switch result {
case let .joinAsPeers(peers, chats, users):
case let .joinAsPeers(_, chats, _):
var subscribers: [PeerId: Int32] = [:]
let peers = chats.compactMap(parseTelegramGroupOrChannel)
for chat in chats {