mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Add reconnection with invite hash if voice chat is already opened in listener mode
This commit is contained in:
parent
afdd1462da
commit
58f5910af3
@ -306,6 +306,7 @@ public protocol PresentationGroupCall: class {
|
||||
|
||||
var memberEvents: Signal<PresentationGroupCallMemberEvent, NoError> { get }
|
||||
|
||||
func reconnect(with invite: String)
|
||||
func reconnect(as peerId: PeerId)
|
||||
func leave(terminateIfPossible: Bool) -> Signal<Bool, NoError>
|
||||
|
||||
|
@ -87,61 +87,69 @@ public func presentPeerReportOptions(context: AccountContext, parent: ViewContro
|
||||
reportReason = .custom
|
||||
}
|
||||
|
||||
var passthrough = passthrough
|
||||
if [.fake, .custom].contains(reportReason) {
|
||||
passthrough = false
|
||||
}
|
||||
|
||||
let displaySuccess = {
|
||||
if let path = getAppBundle().path(forResource: "PoliceCar", ofType: "tgs") {
|
||||
parent?.present(UndoOverlayController(presentationData: presentationData, content: .emoji(path: path, text: presentationData.strings.Report_Succeed), elevatedLayout: false, action: { _ in return false }), in: .current)
|
||||
}
|
||||
}
|
||||
|
||||
let action: (String) -> Void = { message in
|
||||
if passthrough {
|
||||
completion(reportReason, true)
|
||||
} else {
|
||||
switch subject {
|
||||
case let .peer(peerId):
|
||||
let _ = (reportPeer(account: context.account, peerId: peerId, reason: reportReason, message: "")
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
})
|
||||
case let .messages(messageIds):
|
||||
let _ = (reportPeerMessages(account: context.account, messageIds: messageIds, reason: reportReason, message: "")
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
})
|
||||
case let .profilePhoto(peerId, photoId):
|
||||
let _ = (reportPeerPhoto(account: context.account, peerId: peerId, reason: reportReason, message: "")
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
})
|
||||
if passthrough {
|
||||
completion(reportReason, true)
|
||||
} else {
|
||||
let action: (String) -> Void = { message in
|
||||
if passthrough {
|
||||
completion(reportReason, true)
|
||||
} else {
|
||||
switch subject {
|
||||
case let .peer(peerId):
|
||||
let _ = (reportPeer(account: context.account, peerId: peerId, reason: reportReason, message: "")
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
})
|
||||
case let .messages(messageIds):
|
||||
let _ = (reportPeerMessages(account: context.account, messageIds: messageIds, reason: reportReason, message: "")
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
})
|
||||
case let .profilePhoto(peerId, photoId):
|
||||
let _ = (reportPeerPhoto(account: context.account, peerId: peerId, reason: reportReason, message: "")
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let controller = ActionSheetController(presentationData: presentationData, allowInputInset: true)
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
var message = ""
|
||||
var items: [ActionSheetItem] = []
|
||||
items.append(ReportPeerHeaderActionSheetItem(context: context, text: presentationData.strings.Report_AdditionalDetailsText))
|
||||
items.append(ReportPeerDetailsActionSheetItem(context: context, placeholderText: presentationData.strings.Report_AdditionalDetailsPlaceholder, textUpdated: { text in
|
||||
message = text
|
||||
}))
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.Report_Report, color: .accent, font: .bold, enabled: true, action: {
|
||||
dismissAction()
|
||||
|
||||
action(message)
|
||||
}))
|
||||
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: items),
|
||||
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
||||
])
|
||||
parent?.present(controller, in: .window(.root))
|
||||
}
|
||||
|
||||
let controller = ActionSheetController(presentationData: presentationData, allowInputInset: true)
|
||||
let dismissAction: () -> Void = { [weak controller] in
|
||||
controller?.dismissAnimated()
|
||||
}
|
||||
var message = ""
|
||||
var items: [ActionSheetItem] = []
|
||||
items.append(ReportPeerHeaderActionSheetItem(context: context, text: presentationData.strings.Report_AdditionalDetailsText))
|
||||
items.append(ReportPeerDetailsActionSheetItem(context: context, placeholderText: presentationData.strings.Report_AdditionalDetailsPlaceholder, textUpdated: { text in
|
||||
message = text
|
||||
}))
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.Report_Report, color: .accent, font: .bold, enabled: true, action: {
|
||||
dismissAction()
|
||||
|
||||
action(message)
|
||||
}))
|
||||
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: items),
|
||||
ActionSheetItemGroup(items: [ActionSheetButtonItem(title: presentationData.strings.Common_Cancel, action: { dismissAction() })])
|
||||
])
|
||||
parent?.present(controller, in: .window(.root))
|
||||
|
||||
f(.dismissWithoutContent)
|
||||
})))
|
||||
}
|
||||
@ -228,19 +236,19 @@ public func peerReportOptionsController(context: AccountContext, subject: PeerRe
|
||||
let _ = (reportPeer(account: context.account, peerId: peerId, reason: reportReason, message: message)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
completion(nil, true)
|
||||
})
|
||||
case let .messages(messageIds):
|
||||
let _ = (reportPeerMessages(account: context.account, messageIds: messageIds, reason: reportReason, message: message)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
completion(nil, true)
|
||||
})
|
||||
case let .profilePhoto(peerId, photoId):
|
||||
let _ = (reportPeerPhoto(account: context.account, peerId: peerId, reason: reportReason, message: message)
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
displaySuccess()
|
||||
completion(nil, false)
|
||||
completion(nil, true)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
private var initialCall: CachedChannelData.ActiveCall?
|
||||
public let internalId: CallSessionInternalId
|
||||
public let peerId: PeerId
|
||||
private let invite: String?
|
||||
private var invite: String?
|
||||
private var joinAsPeerId: PeerId
|
||||
private var ignorePreviousJoinAsPeerId: (PeerId, UInt32)?
|
||||
|
||||
@ -1716,6 +1716,11 @@ public final class PresentationGroupCallImpl: PresentationGroupCall {
|
||||
}
|
||||
}
|
||||
|
||||
public func reconnect(with invite: String) {
|
||||
self.invite = invite
|
||||
self.requestCall(movingFromBroadcastToRtc: false)
|
||||
}
|
||||
|
||||
public func reconnect(as peerId: PeerId) {
|
||||
if peerId == self.joinAsPeerId {
|
||||
return
|
||||
|
@ -70,6 +70,7 @@ public final class VoiceChatJoinScreen: ViewController {
|
||||
|
||||
let context = self.context
|
||||
let peerId = self.peerId
|
||||
let invite = self.invite
|
||||
let signal = updatedCurrentPeerGroupCall(account: context.account, peerId: peerId)
|
||||
|> castError(GetCurrentGroupCallError.self)
|
||||
|> mapToSignal { call -> Signal<(Peer, GroupCallSummary)?, GetCurrentGroupCallError> in
|
||||
@ -96,19 +97,23 @@ public final class VoiceChatJoinScreen: ViewController {
|
||||
}
|
||||
|> castError(GetCurrentGroupCallError.self)
|
||||
|
||||
let currentGroupCallId: Signal<Int64?, GetCurrentGroupCallError>
|
||||
let currentGroupCall: Signal<(PresentationGroupCall, Int64, Bool)?, GetCurrentGroupCallError>
|
||||
if let callManager = context.sharedContext.callManager {
|
||||
currentGroupCallId = callManager.currentGroupCallSignal
|
||||
currentGroupCall = callManager.currentGroupCallSignal
|
||||
|> castError(GetCurrentGroupCallError.self)
|
||||
|> mapToSignal { call -> Signal<Int64?, GetCurrentGroupCallError> in
|
||||
|> mapToSignal { call -> Signal<(PresentationGroupCall, Int64, Bool)?, GetCurrentGroupCallError> in
|
||||
if let call = call {
|
||||
return call.summaryState
|
||||
|> castError(GetCurrentGroupCallError.self)
|
||||
|> map { state -> Int64? in
|
||||
return state?.info?.id
|
||||
|> map { state -> (PresentationGroupCall, Int64, Bool)? in
|
||||
if let state = state, let info = state.info {
|
||||
return (call, info.id, state.callState.muteState?.canUnmute ?? true)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|> filter { id in
|
||||
return id != nil
|
||||
|> filter { value in
|
||||
return value != nil
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
@ -116,14 +121,18 @@ public final class VoiceChatJoinScreen: ViewController {
|
||||
}
|
||||
|> take(1)
|
||||
} else {
|
||||
currentGroupCallId = .single(nil)
|
||||
currentGroupCall = .single(nil)
|
||||
}
|
||||
|
||||
self.disposable.set(combineLatest(queue: Queue.mainQueue(), signal, cachedGroupCallDisplayAsAvailablePeers(account: context.account, peerId: peerId) |> castError(GetCurrentGroupCallError.self), cachedData, currentGroupCallId).start(next: { [weak self] peerAndCall, availablePeers, cachedData, currentGroupCallId in
|
||||
self.disposable.set(combineLatest(queue: Queue.mainQueue(), signal, cachedGroupCallDisplayAsAvailablePeers(account: context.account, peerId: peerId) |> castError(GetCurrentGroupCallError.self), cachedData, currentGroupCall).start(next: { [weak self] peerAndCall, availablePeers, cachedData, currentGroupCallIdAndCanUnmute in
|
||||
if let strongSelf = self {
|
||||
if let (peer, call) = peerAndCall {
|
||||
if call.info.id == currentGroupCallId {
|
||||
if let (currentGroupCall, currentGroupCallId, canUnmute) = currentGroupCallIdAndCanUnmute, call.info.id == currentGroupCallId {
|
||||
strongSelf.dismiss()
|
||||
|
||||
if let invite = invite, !canUnmute {
|
||||
currentGroupCall.reconnect(with: invite)
|
||||
}
|
||||
strongSelf.context.sharedContext.navigateToCurrentCall()
|
||||
return
|
||||
}
|
||||
|
@ -230,9 +230,30 @@ final class ChatChannelSubscriberInputPanelNode: ChatInputPanelNode {
|
||||
}
|
||||
|
||||
if let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.theme !== interfaceState.theme || previousState?.strings !== interfaceState.strings || previousState?.peerIsMuted != interfaceState.peerIsMuted || previousState?.pinnedMessage != interfaceState.pinnedMessage {
|
||||
|
||||
if let action = actionForPeer(peer: peer, interfaceState: interfaceState, isMuted: interfaceState.peerIsMuted) {
|
||||
let previousAction = self.action
|
||||
self.action = action
|
||||
let (title, color) = titleAndColorForAction(action, theme: interfaceState.theme, strings: interfaceState.strings)
|
||||
|
||||
var offset: CGFloat = 30.0
|
||||
if let previousAction = previousAction, previousAction == .muteNotifications && action == .unmuteNotifications || previousAction == .unmuteNotifications && action == .muteNotifications {
|
||||
if previousAction == .muteNotifications {
|
||||
offset *= -1.0
|
||||
}
|
||||
if let snapshotView = self.button.view.snapshotContentTree() {
|
||||
snapshotView.frame = self.button.frame
|
||||
self.button.supernode?.view.addSubview(snapshotView)
|
||||
|
||||
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
||||
snapshotView?.removeFromSuperview()
|
||||
})
|
||||
snapshotView.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: offset), duration: 0.2, removeOnCompletion: false, additive: true)
|
||||
self.button.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
self.button.layer.animatePosition(from: CGPoint(x: 0.0, y: -offset), to: CGPoint(), duration: 0.2, additive: true)
|
||||
}
|
||||
}
|
||||
|
||||
self.button.setTitle(title, with: Font.regular(17.0), with: color, for: [])
|
||||
} else {
|
||||
self.action = nil
|
||||
|
@ -538,7 +538,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
} else {
|
||||
var canManageGroupCalls = false
|
||||
if let channel = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel {
|
||||
if case .group = channel.info, channel.flags.contains(.isCreator) || channel.hasPermission(.manageCalls) {
|
||||
if channel.flags.contains(.isCreator) || channel.hasPermission(.manageCalls) {
|
||||
canManageGroupCalls = true
|
||||
}
|
||||
} else if let group = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramGroup {
|
||||
|
Loading…
x
Reference in New Issue
Block a user