Merge commit '4a7d5ccb678515214af1a6d8f2916f1ed43f5ed3'

This commit is contained in:
Ali 2021-03-08 13:51:19 +04:00
commit 6eeada12b9
2 changed files with 54 additions and 23 deletions

View File

@ -370,6 +370,7 @@ public final class VoiceChatController: ViewController {
case listening case listening
case speaking case speaking
case invited case invited
case raisedHand
} }
var peer: Peer var peer: Peer
@ -383,7 +384,6 @@ public final class VoiceChatController: ViewController {
var revealed: Bool? var revealed: Bool?
var canManageCall: Bool var canManageCall: Bool
var volume: Int32? var volume: Int32?
var raiseHandStatus: Bool
var stableId: PeerId { var stableId: PeerId {
return self.peer.id return self.peer.id
@ -423,9 +423,6 @@ public final class VoiceChatController: ViewController {
if lhs.volume != rhs.volume { if lhs.volume != rhs.volume {
return false return false
} }
if lhs.raiseHandStatus != rhs.raiseHandStatus {
return false
}
return true return true
} }
@ -523,12 +520,10 @@ public final class VoiceChatController: ViewController {
let icon: VoiceChatParticipantItem.Icon let icon: VoiceChatParticipantItem.Icon
switch peerEntry.state { switch peerEntry.state {
case .listening: case .listening:
var isAbout = false
if let muteState = peerEntry.muteState, muteState.mutedByYou { if let muteState = peerEntry.muteState, muteState.mutedByYou {
text = .text(presentationData.strings.VoiceChat_StatusMutedForYou, .destructive) text = .text(presentationData.strings.VoiceChat_StatusMutedForYou, .destructive)
} else if let about = peerEntry.about, !about.isEmpty { } else if let about = peerEntry.about, !about.isEmpty {
text = .text(about, .generic) text = .text(about, .generic)
isAbout = true
} else { } else {
text = .text(presentationData.strings.VoiceChat_StatusListening, .generic) text = .text(presentationData.strings.VoiceChat_StatusListening, .generic)
} }
@ -555,12 +550,11 @@ public final class VoiceChatController: ViewController {
case .invited: case .invited:
text = .text(presentationData.strings.VoiceChat_StatusInvited, .generic) text = .text(presentationData.strings.VoiceChat_StatusInvited, .generic)
icon = .invite(true) icon = .invite(true)
case .raisedHand:
text = .text(presentationData.strings.VoiceChat_StatusWantsToSpeak, .accent)
icon = .invite(true)
} }
if peerEntry.raiseHandStatus, case let .text(value, type) = text {
text = .text("[hand] \(value)", type)
}
let revealOptions: [VoiceChatParticipantItem.RevealOption] = [] let revealOptions: [VoiceChatParticipantItem.RevealOption] = []
return VoiceChatParticipantItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: context, peer: peer, ssrc: peerEntry.ssrc, presence: peerEntry.presence, text: text, icon: icon, enabled: true, selectable: !peerEntry.isMyPeer || peerEntry.canManageCall, getAudioLevel: { return interaction.getAudioLevel(peer.id) }, getVideo: { return VoiceChatParticipantItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: presentationData.dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: context, peer: peer, ssrc: peerEntry.ssrc, presence: peerEntry.presence, text: text, icon: icon, enabled: true, selectable: !peerEntry.isMyPeer || peerEntry.canManageCall, getAudioLevel: { return interaction.getAudioLevel(peer.id) }, getVideo: {
@ -2748,7 +2742,10 @@ public final class VoiceChatController: ViewController {
let memberState: PeerEntry.State let memberState: PeerEntry.State
var memberMuteState: GroupCallParticipantsContext.Participant.MuteState? var memberMuteState: GroupCallParticipantsContext.Participant.MuteState?
if member.peer.id == self.callState?.myPeerId { if member.raiseHandRating != nil {
memberState = .raisedHand
memberMuteState = member.muteState
} else if member.peer.id == self.callState?.myPeerId {
if muteState == nil { if muteState == nil {
memberState = speakingPeers.contains(member.peer.id) ? .speaking : .listening memberState = speakingPeers.contains(member.peer.id) ? .speaking : .listening
} else { } else {
@ -2770,8 +2767,7 @@ public final class VoiceChatController: ViewController {
state: memberState, state: memberState,
muteState: memberMuteState, muteState: memberMuteState,
canManageCall: self.callState?.canManageCall ?? false, canManageCall: self.callState?.canManageCall ?? false,
volume: member.volume, volume: member.volume
raiseHandStatus: member.raiseHandRating != nil
))) )))
index += 1 index += 1
} }
@ -2792,8 +2788,7 @@ public final class VoiceChatController: ViewController {
state: .invited, state: .invited,
muteState: nil, muteState: nil,
canManageCall: false, canManageCall: false,
volume: nil, volume: nil
raiseHandStatus: false
))) )))
index += 1 index += 1
} }

View File

@ -1724,7 +1724,27 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, _ in items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, _ in
c.dismiss(completion: { c.dismiss(completion: {
if let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController { if let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(strongSelf.peerId), subject: .message(id: message.id, highlight: true))) let currentPeerId = strongSelf.peerId
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(currentPeerId), subject: .message(id: message.id, highlight: true), keepStack: .always, useExisting: false, purposefulAction: {
var viewControllers = navigationController.viewControllers
var indexesToRemove = Set<Int>()
var keptCurrentChatController = false
var index: Int = viewControllers.count - 1
for controller in viewControllers.reversed() {
if let controller = controller as? ChatController, case let .peer(peerId) = controller.chatLocation {
if peerId == currentPeerId && !keptCurrentChatController {
keptCurrentChatController = true
} else {
indexesToRemove.insert(index)
}
} else if controller is PeerInfoScreen {
indexesToRemove.insert(index)
}
index -= 1
}
viewControllers.remove(atOffsets: IndexSet(indexesToRemove))
navigationController.setViewControllers(viewControllers, animated: false)
}))
} }
}) })
}))) })))
@ -1844,7 +1864,27 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
items.append(.action(ContextMenuActionItem(text: strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, f in items.append(.action(ContextMenuActionItem(text: strings.SharedMedia_ViewInChat, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/GoToMessage"), color: theme.contextMenu.primaryColor) }, action: { c, f in
c.dismiss(completion: { c.dismiss(completion: {
if let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController { if let strongSelf = self, let navigationController = strongSelf.controller?.navigationController as? NavigationController {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(strongSelf.peerId), subject: .message(id: message.id, highlight: true))) let currentPeerId = strongSelf.peerId
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(currentPeerId), subject: .message(id: message.id, highlight: true), keepStack: .always, useExisting: false, purposefulAction: {
var viewControllers = navigationController.viewControllers
var indexesToRemove = Set<Int>()
var keptCurrentChatController = false
var index: Int = viewControllers.count - 1
for controller in viewControllers.reversed() {
if let controller = controller as? ChatController, case let .peer(peerId) = controller.chatLocation {
if peerId == currentPeerId && !keptCurrentChatController {
keptCurrentChatController = true
} else {
indexesToRemove.insert(index)
}
} else if controller is PeerInfoScreen {
indexesToRemove.insert(index)
}
index -= 1
}
viewControllers.remove(atOffsets: IndexSet(indexesToRemove))
navigationController.setViewControllers(viewControllers, animated: false)
}))
} }
}) })
}))) })))
@ -3702,11 +3742,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
if false, let currentPeerId = currentPeerId { if let controller = strongSelf.controller {
if let navigationController = (strongSelf.controller?.navigationController as? NavigationController) {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(currentPeerId)))
}
} else if let controller = strongSelf.controller {
let displayTitle = peer?.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder) ?? "" let displayTitle = peer?.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder) ?? ""
controller.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.UserInfo_StartSecretChatConfirmation(displayTitle).0, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.UserInfo_StartSecretChatStart, action: { controller.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.UserInfo_StartSecretChatConfirmation(displayTitle).0, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {}), TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.UserInfo_StartSecretChatStart, action: {
guard let strongSelf = self else { guard let strongSelf = self else {