Display an error when trying to create a voice chat as an anonymous admin

This commit is contained in:
Ali 2020-12-06 16:58:43 +00:00
parent dd0edaefa8
commit 76aecfbcea
2 changed files with 15 additions and 3 deletions

View File

@ -114,7 +114,6 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
)
}
|> mapError { _ -> GetCurrentGroupCallError in
return .generic
}
}
}
@ -122,6 +121,7 @@ public func getCurrentGroupCall(account: Account, callId: Int64, accessHash: Int
public enum CreateGroupCallError {
case generic
case anonymousNotAllowed
}
public func createGroupCall(account: Account, peerId: PeerId) -> Signal<GroupCallInfo, CreateGroupCallError> {
@ -135,7 +135,10 @@ public func createGroupCall(account: Account, peerId: PeerId) -> Signal<GroupCal
}
return account.network.request(Api.functions.phone.createGroupCall(channel: inputPeer, randomId: Int32.random(in: Int32.min ... Int32.max)))
|> mapError { _ -> CreateGroupCallError in
|> mapError { error -> CreateGroupCallError in
if error.errorDescription == "ANONYMOUS_CALLS_DISABLED" {
return .anonymousNotAllowed
}
return .generic
}
|> mapToSignal { result -> Signal<GroupCallInfo, CreateGroupCallError> in

View File

@ -3247,13 +3247,22 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
return
}
strongSelf.context.joinGroupCall(peerId: peerId, activeCall: CachedChannelData.ActiveCall(id: info.id, accessHash: info.accessHash), sourcePanel: nil)
}, error: { [weak self] _ in
}, error: { [weak self] error in
dismissStatus?()
guard let strongSelf = self else {
return
}
strongSelf.headerNode.navigationButtonContainer.performAction?(.cancel)
let text: String
switch error {
case .generic:
text = strongSelf.presentationData.strings.Login_UnknownError
case .anonymousNotAllowed:
text = strongSelf.presentationData.strings.VoiceChat_AnonymousDisabledAlertText
}
strongSelf.controller?.present(textAlertController(context: strongSelf.context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
}, completed: { [weak self] in
dismissStatus?()