Voice chat fixes

This commit is contained in:
Ali 2020-11-30 18:21:21 +04:00
parent e0d2201956
commit b88da2e512
7 changed files with 2671 additions and 2624 deletions

View File

@ -2493,6 +2493,9 @@ Unused sets are archived when you add more.";
"Call.CallInProgressMessage" = "Finish call with %1$@ and start a new one with %2$@?";
"Call.ExternalCallInProgressMessage" = "Please finish the current call first.";
"Call.VoiceChatInProgressTitle" = "Voice Chat in Progress";
"Call.VoiceChatInProgressMessage" = "Leave voice chat in %1$@ and start a new one with %2$@?";
"Call.Message" = "Message";
"UserInfo.TapToCall" = "Tap to make an end-to-end encrypted call";
@ -2625,7 +2628,7 @@ Unused sets are archived when you add more.";
"Channel.AdminLog.CanAddAdmins" = "Add New Admins";
"Channel.AdminLog.CanBeAnonymous" = "Remain Anonymous";
"Channel.AdminLog.CanEditMessages" = "Edit Messages";
"Channel.AdminLog.CanManageCalls" = "Manage Calls";
"Channel.AdminLog.CanManageCalls" = "Manage Voice Chats";
"Channel.AdminLog.MessageToggleInvitesOn" = "%@ enabled group invites";
"Channel.AdminLog.MessageToggleInvitesOff" = "%@ disabled group invites";
@ -5972,3 +5975,5 @@ Sorry for the inconvenience.";
"VoiceChat.Panel.MembersSpeaking_any" = "%@ members speaking";
"ChannelInfo.CreateVoiceChat" = "Create Voice Chat";
"VoiceChat.AnonymousDisabledAlertText" = "Sorry, you can't join voice chat as an anonymous admin.";

View File

@ -497,10 +497,16 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
if let clientParams = joinCallResult.callInfo.clientParams {
strongSelf.updateSessionState(internalState: .estabilished(info: joinCallResult.callInfo, clientParams: clientParams, localSsrc: ssrc, initialState: joinCallResult.state), audioSessionControl: strongSelf.audioSessionControl)
}
}, error: { _ in
}, error: { error in
guard let strongSelf = self else {
return
}
if case .anonymousNotAllowed = error {
let presentationData = strongSelf.accountContext.sharedContext.currentPresentationData.with { $0 }
strongSelf.accountContext.sharedContext.mainWindow?.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: presentationData), title: nil, text: presentationData.strings.VoiceChat_AnonymousDisabledAlertText, actions: [
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})
]), on: .root, blockInteraction: false, completion: {})
}
strongSelf._canBeRemoved.set(.single(true))
}))
}))
@ -691,14 +697,29 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
if terminateIfPossible {
self.leaveDisposable.set((stopGroupCall(account: self.account, peerId: self.peerId, callId: callInfo.id, accessHash: callInfo.accessHash)
|> deliverOnMainQueue).start(completed: { [weak self] in
self?._canBeRemoved.set(.single(true))
guard let strongSelf = self else {
return
}
strongSelf.callContext?.stop()
strongSelf.callContext = nil
strongSelf._canBeRemoved.set(.single(true))
}))
} else {
self.leaveDisposable.set((leaveGroupCall(account: self.account, callId: callInfo.id, accessHash: callInfo.accessHash, source: localSsrc)
|> deliverOnMainQueue).start(error: { [weak self] _ in
self?._canBeRemoved.set(.single(true))
guard let strongSelf = self else {
return
}
strongSelf.callContext?.stop()
strongSelf.callContext = nil
strongSelf._canBeRemoved.set(.single(true))
}, completed: { [weak self] in
self?._canBeRemoved.set(.single(true))
guard let strongSelf = self else {
return
}
strongSelf.callContext?.stop()
strongSelf.callContext = nil
strongSelf._canBeRemoved.set(.single(true))
}))
}
} else {

View File

@ -386,7 +386,7 @@ public final class VoiceChatController: ViewController {
}
default:
if peer.id != strongSelf.context.account.peerId {
if let callState = strongSelf.callState, (callState.canManageCall || callState.adminIds.contains(strongSelf.context.account.peerId)) {
if let callState = strongSelf.callState, (callState.canManageCall || callState.adminIds.contains(strongSelf.context.account.peerId)), !callState.adminIds.contains(peer.id) {
if let muteState = entry.muteState, !muteState.canUnmute {
items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.VoiceChat_UnmutePeer, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Call/Context Menu/Unmute"), color: theme.actionSheet.primaryTextColor)
@ -613,17 +613,24 @@ public final class VoiceChatController: ViewController {
}
var items: [ContextMenuItem] = []
/*items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.VoiceChat_SpeakPermissionEveryone, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
f(.dismissWithoutContent)
})))
items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.VoiceChat_SpeakPermissionAdmin, icon: { _ in return nil}, action: { _, f in
f(.dismissWithoutContent)
})))
items.append(.separator)*/
if let callState = strongSelf.callState, callState.canManageCall {
items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.VoiceChat_SpeakPermissionEveryone, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Check"), color: theme.actionSheet.primaryTextColor)
}, action: { _, f in
f(.dismissWithoutContent)
})))
items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.VoiceChat_SpeakPermissionAdmin, icon: { _ in return nil}, action: { _, f in
f(.dismissWithoutContent)
})))
}
if !items.isEmpty {
items.append(.separator)
}
items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.VoiceChat_Share, icon: { theme in
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Link"), color: theme.actionSheet.primaryTextColor)
}, action: { [weak self] _, f in
@ -698,7 +705,7 @@ public final class VoiceChatController: ViewController {
super.didLoad()
let titleView = VoiceChatControllerTitleView(theme: self.presentationData.theme)
titleView.set(title: "Voice Chat", subtitle: "connecting")
titleView.set(title: self.presentationData.strings.VoiceChat_Title, subtitle: self.presentationData.strings.SocksProxySetup_ProxyStatusConnecting)
self.controller?.navigationItem.titleView = titleView
let longTapRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.actionButtonPressGesture(_:)))

View File

@ -254,6 +254,7 @@ public func getGroupCallParticipants(account: Account, callId: Int64, accessHash
public enum JoinGroupCallError {
case generic
case anonymousNotAllowed
}
public struct JoinGroupCallResult {
@ -267,7 +268,10 @@ public func joinGroupCall(account: Account, peerId: PeerId, callId: Int64, acces
flags |= (1 << 0)
}
return account.network.request(Api.functions.phone.joinGroupCall(flags: flags, call: .inputGroupCall(id: callId, accessHash: accessHash), params: .dataJSON(data: joinPayload)))
|> mapError { _ -> JoinGroupCallError in
|> mapError { error -> JoinGroupCallError in
if error.errorDescription == "GROUP_CALL_ANONYMOUS_FORBIDDEN" {
return .anonymousNotAllowed
}
return .generic
}
|> mapToSignal { updates -> Signal<JoinGroupCallResult, JoinGroupCallError> in

View File

@ -639,6 +639,11 @@ extension StoreMessage {
if (flags & (1 << 4)) != 0 {
notificationFlags.insert(.personal)
}
if (flags & (1 << 4)) != 0 {
notificationFlags.insert(.personal)
let notConsumed = (flags & (1 << 5)) != 0
attributes.append(ConsumablePersonalMentionMessageAttribute(consumed: !notConsumed, pending: false))
}
if (flags & (1 << 13)) != 0 {
notificationFlags.insert(.muted)
}