Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2021-03-14 21:33:10 +04:00
commit b3e5ac68b0
204 changed files with 94 additions and 4 deletions

View File

@ -474,6 +474,8 @@ final class CallListControllerNode: ASDisplayNode {
} else {
previousWasEmptyOrSingleHole = true
}
var disableAnimations = false
if previousWasEmptyOrSingleHole {
reason = .initial
@ -482,7 +484,26 @@ final class CallListControllerNode: ASDisplayNode {
}
} else {
if previous?.originalView === update.view {
let previousCalls = previous?.filteredEntries.compactMap { item -> PeerId? in
switch item {
case let .groupCall(peer, _, _):
return peer.id
default:
return nil
}
}
let updatedCalls = processedView.filteredEntries.compactMap { item -> PeerId? in
switch item {
case let .groupCall(peer, _, _):
return peer.id
default:
return nil
}
}
reason = .interactiveChanges
if previousCalls != updatedCalls {
disableAnimations = true
}
} else {
switch update.type {
case .Initial:
@ -500,7 +521,7 @@ final class CallListControllerNode: ASDisplayNode {
}
}
return preparedCallListNodeViewTransition(from: previous, to: processedView, reason: reason, disableAnimations: false, account: context.account, scrollPosition: update.scrollPosition)
return preparedCallListNodeViewTransition(from: previous, to: processedView, reason: reason, disableAnimations: disableAnimations, account: context.account, scrollPosition: update.scrollPosition)
|> map({ mappedCallListNodeViewListTransition(context: context, presentationData: state.presentationData, showSettings: showSettings, nodeInteraction: nodeInteraction, transition: $0) })
|> runOn(prepareOnMainQueue ? Queue.mainQueue() : viewProcessingQueue)
}

View File

@ -1422,7 +1422,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
for participant in participants {
members.participants.append(participant)
var participant = participant
if topParticipants.count < 3 {
topParticipants.append(participant)
@ -1470,6 +1470,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
var filteredMuteState = participant.muteState
if isReconnectingAsSpeaker || strongSelf.currentConnectionMode != .rtc {
filteredMuteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: false)
participant.muteState = filteredMuteState
}
if let muteState = filteredMuteState {
@ -1507,6 +1508,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
updatedInvitedPeers.remove(at: index)
didUpdateInvitedPeers = true
}
members.participants.append(participant)
}
members.totalCount = state.totalCount

View File

@ -414,7 +414,6 @@ func voiceChatTitleEditController(sharedContext: SharedAccountContext, account:
let actions: [TextAlertAction] = [TextAlertAction(type: .genericAction, title: presentationData.strings.Common_Cancel, action: {
dismissImpl?(true)
apply(nil)
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Done, action: {
applyImpl?()
})]

View File

@ -489,6 +489,67 @@ public func joinGroupCall(account: Account, peerId: PeerId, joinAs: PeerId?, cal
}
})
var state = state
for update in updates.allUpdates {
switch update {
case let .updateGroupCallParticipants(_, participants, _):
loop: for participant in participants {
switch participant {
case let .groupCallParticipant(flags, apiPeerId, date, activeDate, source, volume, about, raiseHandRating):
let peerId: PeerId
switch apiPeerId {
case let .peerUser(userId):
peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: userId)
case let .peerChat(chatId):
peerId = PeerId(namespace: Namespaces.Peer.CloudGroup, id: chatId)
case let .peerChannel(channelId):
peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: channelId)
}
let ssrc = UInt32(bitPattern: source)
guard let peer = transaction.getPeer(peerId) else {
continue loop
}
let muted = (flags & (1 << 0)) != 0
let mutedByYou = (flags & (1 << 9)) != 0
var muteState: GroupCallParticipantsContext.Participant.MuteState?
if muted {
let canUnmute = (flags & (1 << 2)) != 0
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: canUnmute, mutedByYou: mutedByYou)
} else if mutedByYou {
muteState = GroupCallParticipantsContext.Participant.MuteState(canUnmute: false, mutedByYou: mutedByYou)
}
let jsonParams: String? = nil
/*if let params = params {
switch params {
case let .dataJSON(data):
jsonParams = data
}
}*/
if !state.participants.contains(where: { $0.peer.id == peer.id }) {
state.participants.append(GroupCallParticipantsContext.Participant(
peer: peer,
ssrc: ssrc,
jsonParams: jsonParams,
joinTimestamp: date,
raiseHandRating: raiseHandRating,
hasRaiseHand: raiseHandRating != nil,
activityTimestamp: activeDate.flatMap(Double.init),
activityRank: nil,
muteState: muteState,
volume: volume,
about: about
))
}
}
}
default:
break
}
}
state.participants.sort()
updatePeers(transaction: transaction, peers: peers, update: { _, updated -> Peer in
return updated
})
@ -1804,8 +1865,14 @@ public func groupCallDisplayAsAvailablePeers(network: Network, postbox: Postbox,
return .complete()
}
return network.request(Api.functions.phone.getGroupCallJoinAs(peer: inputPeer))
|> retryRequest
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.phone.JoinAsPeers?, NoError> in
return .single(nil)
}
|> mapToSignal { result in
guard let result = result else {
return .single([])
}
switch result {
case let .joinAsPeers(_, chats, _):
var subscribers: [PeerId: Int32] = [:]

Some files were not shown because too many files have changed in this diff Show More