diff --git a/submodules/TelegramCallsUI/Sources/PresentationCall.swift b/submodules/TelegramCallsUI/Sources/PresentationCall.swift index 10a083f8b3..46dc2b77c9 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCall.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCall.swift @@ -658,6 +658,8 @@ public final class PresentationCallImpl: PresentationCall { self.sharedAudioContext = nil self.sessionState = nil self.callContextState = nil + let debugLogValue = Promise() + self.ongoingContext?.stop(sendDebugLogs: false, debugLogValue: debugLogValue) self.ongoingContext = nil self.ongoingContextStateDisposable?.dispose() self.ongoingContextStateDisposable = nil diff --git a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift index 7d3b79b3fd..e7b6433db6 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift @@ -973,10 +973,6 @@ public final class PresentationCallManagerImpl: PresentationCallManager { return .joined } - public func switchToConference(call: PresentationCall) { - - } - private func startGroupCall( accountContext: AccountContext, peerId: PeerId, diff --git a/submodules/TelegramCallsUI/Sources/VideoChatParticipantStatusComponent.swift b/submodules/TelegramCallsUI/Sources/VideoChatParticipantStatusComponent.swift index 5b480bac46..eb875e466f 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatParticipantStatusComponent.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatParticipantStatusComponent.swift @@ -5,6 +5,7 @@ import ComponentFlow import TelegramPresentationData import TelegramCore import LottieComponent +import BundleIconComponent final class VideoChatParticipantStatusComponent: Component { let muteState: GroupCallParticipantsContext.Participant.MuteState? @@ -222,3 +223,74 @@ final class VideoChatParticipantStatusComponent: Component { return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) } } + +final class VideoChatParticipantInvitedStatusComponent: Component { + let theme: PresentationTheme + + init(theme: PresentationTheme) { + self.theme = theme + } + + static func ==(lhs: VideoChatParticipantInvitedStatusComponent, rhs: VideoChatParticipantInvitedStatusComponent) -> Bool { + if lhs.theme !== rhs.theme { + return false + } + return true + } + + final class View: UIView { + private var icon = ComponentView() + + private var component: VideoChatParticipantInvitedStatusComponent? + private var isUpdating: Bool = false + + override init(frame: CGRect) { + super.init(frame: frame) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + deinit { + } + + func update(component: VideoChatParticipantInvitedStatusComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { + self.isUpdating = true + defer { + self.isUpdating = false + } + + let size = CGSize(width: 44.0, height: 44.0) + + let iconTintColor = UIColor(white: 1.0, alpha: 0.4) + let iconSize = self.icon.update( + transition: transition, + component: AnyComponent(BundleIconComponent( + name: "Call/GroupPeerInvited", + tintColor: iconTintColor + )), + environment: {}, + containerSize: size + ) + + let iconFrame = CGRect(origin: CGPoint(x: floor((size.width - iconSize.width) * 0.5) - 2.0, y: floor((size.height - iconSize.height) * 0.5)), size: iconSize) + if let iconView = self.icon.view { + if iconView.superview == nil { + self.addSubview(iconView) + } + transition.setFrame(view: iconView, frame: iconFrame) + } + + return size + } + } + + func makeView() -> View { + return View() + } + + func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment, transition: ComponentTransition) -> CGSize { + return view.update(component: self, availableSize: availableSize, state: state, environment: environment, transition: transition) + } +} diff --git a/submodules/TelegramCallsUI/Sources/VideoChatParticipantsComponent.swift b/submodules/TelegramCallsUI/Sources/VideoChatParticipantsComponent.swift index 879ebc665e..5f975d1a73 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatParticipantsComponent.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatParticipantsComponent.swift @@ -1258,7 +1258,7 @@ final class VideoChatParticipantsComponent: Component { subtitle: subtitle, subtitleAccessory: .none, presence: nil, - rightAccessoryComponent: rightAccessoryComponent, + rightAccessoryComponent: AnyComponentWithIdentity(id: 0, component: rightAccessoryComponent), selectionState: .none, hasNext: false, extractedTheme: PeerListItemComponent.ExtractedTheme( @@ -1295,6 +1295,10 @@ final class VideoChatParticipantsComponent: Component { subtitle = PeerListItemComponent.Subtitle(text: "invited", color: .neutral) } + let rightAccessoryComponent: AnyComponent = AnyComponent(VideoChatParticipantInvitedStatusComponent( + theme: component.theme + )) + peerItemComponent = PeerListItemComponent( context: component.call.accountContext, theme: component.theme, @@ -1313,7 +1317,7 @@ final class VideoChatParticipantsComponent: Component { subtitle: subtitle, subtitleAccessory: .none, presence: nil, - rightAccessoryComponent: nil, + rightAccessoryComponent: AnyComponentWithIdentity(id: 1, component: rightAccessoryComponent), selectionState: .none, hasNext: false, extractedTheme: PeerListItemComponent.ExtractedTheme( diff --git a/submodules/TelegramCallsUI/Sources/VideoChatScreenParticipantContextMenu.swift b/submodules/TelegramCallsUI/Sources/VideoChatScreenParticipantContextMenu.swift index 0161d1a73d..9cbef0c378 100644 --- a/submodules/TelegramCallsUI/Sources/VideoChatScreenParticipantContextMenu.swift +++ b/submodules/TelegramCallsUI/Sources/VideoChatScreenParticipantContextMenu.swift @@ -271,11 +271,17 @@ extension VideoChatScreenComponent.View { guard let self, case let .group(groupCall) = self.currentCall else { return } - guard let peerId = groupCall.peerId else { - return + + let chatPeer: Signal + if let peerId = groupCall.peerId { + chatPeer = groupCall.accountContext.engine.data.get( + TelegramEngine.EngineData.Item.Peer.Peer(id: peerId) + ) + } else { + chatPeer = .single(nil) } - let _ = (groupCall.accountContext.account.postbox.loadedPeerWithId(peerId) + let _ = (chatPeer |> deliverOnMainQueue).start(next: { [weak self] chatPeer in guard let self, let environment = self.environment, case let .group(groupCall) = self.currentCall else { return @@ -286,7 +292,9 @@ extension VideoChatScreenComponent.View { var items: [ActionSheetItem] = [] let nameDisplayOrder = presentationData.nameDisplayOrder - items.append(DeleteChatPeerActionSheetItem(context: groupCall.accountContext, peer: EnginePeer(peer), chatPeer: EnginePeer(chatPeer), action: .removeFromGroup, strings: environment.strings, nameDisplayOrder: nameDisplayOrder)) + if let chatPeer { + items.append(DeleteChatPeerActionSheetItem(context: groupCall.accountContext, peer: EnginePeer(peer), chatPeer: chatPeer, action: .removeFromGroup, strings: environment.strings, nameDisplayOrder: nameDisplayOrder)) + } items.append(ActionSheetButtonItem(title: environment.strings.VoiceChat_RemovePeerRemove, color: .destructive, action: { [weak self, weak actionSheet] in actionSheet?.dismissAnimated() @@ -294,15 +302,14 @@ extension VideoChatScreenComponent.View { guard let self, let environment = self.environment, case let .group(groupCall) = self.currentCall else { return } - guard let callPeerId = groupCall.peerId else { - return - } - let _ = groupCall.accountContext.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: groupCall.accountContext.engine, peerId: callPeerId, memberId: peer.id, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: Int32.max)).start() if groupCall.isConference { groupCall.kickPeer(id: peer.id) } else { - groupCall.removedPeer(peer.id) + if let callPeerId = groupCall.peerId { + let _ = groupCall.accountContext.peerChannelMemberCategoriesContextsManager.updateMemberBannedRights(engine: groupCall.accountContext.engine, peerId: callPeerId, memberId: peer.id, bannedRights: TelegramChatBannedRights(flags: [.banReadMessages], untilDate: Int32.max)).start() + groupCall.removedPeer(peer.id) + } } self.presentUndoOverlay(content: .banned(text: environment.strings.VoiceChat_RemovedPeerText(EnginePeer(peer).displayTitle(strings: environment.strings, displayOrder: nameDisplayOrder)).string), action: { _ in return false }) diff --git a/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift b/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift index 391095f941..8408cee489 100644 --- a/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift +++ b/submodules/TelegramUI/Components/Stories/PeerListItemComponent/Sources/PeerListItemComponent.swift @@ -235,7 +235,7 @@ public final class PeerListItemComponent: Component { let subtitleAccessory: SubtitleAccessory let presence: EnginePeer.Presence? let rightAccessory: RightAccessory - let rightAccessoryComponent: AnyComponent? + let rightAccessoryComponent: AnyComponentWithIdentity? let reaction: Reaction? let story: EngineStoryItem? let message: EngineMessage? @@ -266,7 +266,7 @@ public final class PeerListItemComponent: Component { subtitleAccessory: SubtitleAccessory, presence: EnginePeer.Presence?, rightAccessory: RightAccessory = .none, - rightAccessoryComponent: AnyComponent? = nil, + rightAccessoryComponent: AnyComponentWithIdentity? = nil, reaction: Reaction? = nil, story: EngineStoryItem? = nil, message: EngineMessage? = nil, @@ -763,9 +763,14 @@ public final class PeerListItemComponent: Component { height = 40.0 + verticalInset * 2.0 } } + + if let rightAccessoryComponentView = self.rightAccessoryComponentView, component.rightAccessoryComponent?.id != previousComponent?.rightAccessoryComponent?.id { + self.rightAccessoryComponentView = nil + rightAccessoryComponentView.view?.removeFromSuperview() + } var rightAccessoryComponentSize: CGSize? - if let rightAccessoryComponent = component.rightAccessoryComponent { + if let rightAccessoryComponent = component.rightAccessoryComponent?.component { var rightAccessoryComponentTransition = transition let rightAccessoryComponentView: ComponentView if let current = self.rightAccessoryComponentView { diff --git a/submodules/TelegramUI/Images.xcassets/Call/GroupPeerInvited.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Call/GroupPeerInvited.imageset/Contents.json new file mode 100644 index 0000000000..95e165d835 --- /dev/null +++ b/submodules/TelegramUI/Images.xcassets/Call/GroupPeerInvited.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "invited.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/submodules/TelegramUI/Images.xcassets/Call/GroupPeerInvited.imageset/invited.pdf b/submodules/TelegramUI/Images.xcassets/Call/GroupPeerInvited.imageset/invited.pdf new file mode 100644 index 0000000000..f6871e70f3 Binary files /dev/null and b/submodules/TelegramUI/Images.xcassets/Call/GroupPeerInvited.imageset/invited.pdf differ diff --git a/submodules/TgVoipWebrtc/tgcalls b/submodules/TgVoipWebrtc/tgcalls index fd1cfbd815..579cae3c3c 160000 --- a/submodules/TgVoipWebrtc/tgcalls +++ b/submodules/TgVoipWebrtc/tgcalls @@ -1 +1 @@ -Subproject commit fd1cfbd8151b2c32d5471a4f5431faa6274ce421 +Subproject commit 579cae3c3c70c6ed8bc0d88cc41de28bd50a7f1b