Fix voice chat missing peer requests

This commit is contained in:
Ali 2021-01-29 18:11:32 +05:00
parent 7608fff064
commit 1e1d9ae977
8 changed files with 3326 additions and 3310 deletions

View File

@ -5959,6 +5959,7 @@ Sorry for the inconvenience.";
"ChatImportActivity.ErrorInvalidChatType" = "Wrong type of chat for the messages you are trying to import.";
"ChatImportActivity.ErrorUserBlocked" = "Unable to import messages due to privacy settings.";
"ChatImportActivity.ErrorGeneric" = "An error occurred.";
"ChatImportActivity.ErrorLimitExceeded" = "Limit exceeded. Please try again later.";
"ChatImportActivity.Success" = "Chat imported\nsuccessfully.";
"VoiceOver.Chat.GoToOriginalMessage" = "Go to message";

View File

@ -57,6 +57,7 @@ private final class ImportManager {
case chatAdminRequired
case invalidChatType
case userBlocked
case limitExceeded
}
enum State {
@ -119,6 +120,8 @@ private final class ImportManager {
return .generic
case .userBlocked:
return .userBlocked
case .limitExceeded:
return .limitExceeded
}
}
|> deliverOnMainQueue).start(next: { [weak self] session in
@ -533,6 +536,8 @@ public final class ChatImportActivityScreen: ViewController {
errorText = self.presentationData.strings.ChatImportActivity_ErrorGeneric
case .userBlocked:
errorText = self.presentationData.strings.ChatImportActivity_ErrorUserBlocked
case .limitExceeded:
errorText = self.presentationData.strings.ChatImportActivity_ErrorLimitExceeded
}
self.statusText.attributedText = NSAttributedString(string: errorText, font: Font.regular(17.0), textColor: self.presentationData.theme.list.itemDestructiveColor)
case .done:

View File

@ -891,6 +891,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
var result: [(PeerId, UInt32, Float, Bool)] = []
var myLevel: Float = 0.0
var myLevelHasVoice: Bool = false
var missingSsrcs = Set<UInt32>()
for (ssrcKey, level, hasVoice) in levels {
var peerId: PeerId?
let ssrcValue: UInt32
@ -910,6 +911,8 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
}
}
result.append((peerId, ssrcValue, level, hasVoice))
} else if ssrcValue != 0 {
missingSsrcs.insert(ssrcValue)
}
}
@ -918,6 +921,10 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
let mappedLevel = myLevel * 1.5
strongSelf.myAudioLevelPipe.putNext(mappedLevel)
strongSelf.processMyAudioLevel(level: mappedLevel, hasVoice: myLevelHasVoice)
if !missingSsrcs.isEmpty {
strongSelf.participantsContext?.ensureHaveParticipants(ssrcs: missingSsrcs)
}
}))
}
}

View File

@ -1229,7 +1229,7 @@ public final class VoiceChatController: ViewController {
guard let strongSelf = self else {
return
}
if case let .known(value) = offset, value < 100.0 {
if case let .known(value) = offset, value < 200.0 {
if let loadMoreToken = strongSelf.currentCallMembers?.1 {
strongSelf.currentLoadToken = loadMoreToken
strongSelf.call.loadMoreMembers(token: loadMoreToken)

View File

@ -16,6 +16,7 @@ public enum ChatHistoryImport {
case chatAdminRequired
case invalidChatType
case userBlocked
case limitExceeded
}
public enum ParsedInfo {
@ -64,16 +65,17 @@ public enum ChatHistoryImport {
guard let inputPeer = inputPeer else {
return .fail(.generic)
}
return account.network.request(Api.functions.messages.initHistoryImport(peer: inputPeer, file: inputFile, mediaCount: mediaCount))
return account.network.request(Api.functions.messages.initHistoryImport(peer: inputPeer, file: inputFile, mediaCount: mediaCount), automaticFloodWait: false)
|> mapError { error -> InitImportError in
switch error.errorDescription {
case "CHAT_ADMIN_REQUIRED":
if error.errorDescription == "CHAT_ADMIN_REQUIRED" {
return .chatAdminRequired
case "IMPORT_PEER_TYPE_INVALID":
} else if error.errorDescription == "IMPORT_PEER_TYPE_INVALID" {
return .invalidChatType
case "USER_IS_BLOCKED":
} else if error.errorDescription == "USER_IS_BLOCKED" {
return .userBlocked
default:
} else if error.errorDescription == "FLOOD_WAIT" {
return .limitExceeded
} else {
return .generic
}
}

View File

@ -949,7 +949,7 @@ public final class GroupCallParticipantsContext {
self.ensureHaveParticipants(ssrcs: Set(ids.map { $0.1 }))
}
private func ensureHaveParticipants(ssrcs: Set<UInt32>) {
public func ensureHaveParticipants(ssrcs: Set<UInt32>) {
var missingSsrcs = Set<UInt32>()
var existingSsrcs = Set<UInt32>()