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

This commit is contained in:
Ilya Laktyushin 2021-03-12 20:44:55 +04:00
commit ec9908ec2f
6 changed files with 38 additions and 11 deletions

View File

@ -426,6 +426,8 @@ final class CallListControllerNode: ASDisplayNode {
case let .MessageEntry(_, _, _, _, _, renderedPeer, _, _, _, _):
if let channel = renderedPeer.peer as? TelegramChannel, channel.flags.contains(.hasActiveVoiceChat) {
result.append(channel)
} else if let group = renderedPeer.peer as? TelegramGroup, group.flags.contains(.hasActiveVoiceChat) {
result.append(group)
}
default:
break

View File

@ -1267,6 +1267,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
}
var contentHeight = max(layout.size.height, max(layout.size.height, originalActionsFrame.maxY + actionsBottomInset) - originalContentFrame.minY + contentTopInset)
contentHeight = max(contentHeight, actionsSize.height + originalActionsFrame.minY + actionsBottomInset)
var overflowOffset: CGFloat
var contentContainerFrame: CGRect

View File

@ -1310,9 +1310,11 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
|> 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

@ -2346,7 +2346,7 @@ public final class VoiceChatController: ViewController {
}
self.isFullscreen = isFullscreen
self.controller?.statusBar.statusBarStyle = isFullscreen ? .White : .Ignore
self.controller?.statusBar.updateStatusBarStyle(isFullscreen ? .White : .Ignore, animated: true)
var size = layout.size
if case .regular = layout.metrics.widthClass {

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)
@ -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,
@ -1777,9 +1782,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 {

View File

@ -258,8 +258,27 @@ final class AuthorizedApplicationContext {
}
}))
let postbox = context.account.postbox
self.notificationMessagesDisposable.set((context.account.stateManager.notificationMessages
|> mapToSignal { messageList -> Signal<[([Message], PeerGroupId, Bool)], NoError> in
return postbox.transaction { transaction -> [([Message], PeerGroupId, Bool)] in
return messageList.filter { item in
guard let message = item.0.first else {
return false
}
let inclusion = transaction.getPeerChatListInclusion(message.id.peerId)
if case .notIncluded = inclusion {
return false
}
return true
}
}
}
|> deliverOn(Queue.mainQueue())).start(next: { [weak self] messageList in
if messageList.isEmpty {
return
}
if let strongSelf = self, let (messages, _, notify) = messageList.last, let firstMessage = messages.first {
if UIApplication.shared.applicationState == .active {
var chatIsVisible = false