From 9eddffb694ade50cfe42d69c2813d6a0bee8f8ea Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Tue, 11 Nov 2025 18:29:30 +0800 Subject: [PATCH] Various improvements --- .../Sources/Components/MediaStreamComponent.swift | 1 + .../Sources/Components/MediaStreamVideoComponent.swift | 8 +++++++- .../Sources/StoryItemContentComponent.swift | 1 + .../Sources/StoryItemSetContainerComponent.swift | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift index 8a1e3d4fb9..5edc8d2731 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamComponent.swift @@ -371,6 +371,7 @@ public final class MediaStreamComponent: CombinedComponent { isFullscreen: isFullscreen, videoLoading: context.state.videoStalled, callPeer: context.state.chatPeer, + enablePictureInPicture: true, activatePictureInPicture: activatePictureInPicture, deactivatePictureInPicture: deactivatePictureInPicture, bringBackControllerForPictureInPictureDeactivation: { [weak call] completed in diff --git a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift index 38fd3cfdb1..eece3a8a6a 100644 --- a/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift +++ b/submodules/TelegramCallsUI/Sources/Components/MediaStreamVideoComponent.swift @@ -19,6 +19,7 @@ public final class MediaStreamVideoComponent: Component { let isVisible: Bool let isAdmin: Bool let peerTitle: String + let enablePictureInPicture: Bool let activatePictureInPicture: ActionSlot> let deactivatePictureInPicture: ActionSlot let bringBackControllerForPictureInPictureDeactivation: (@escaping () -> Void) -> Void @@ -40,6 +41,7 @@ public final class MediaStreamVideoComponent: Component { isFullscreen: Bool, videoLoading: Bool, callPeer: Peer?, + enablePictureInPicture: Bool, activatePictureInPicture: ActionSlot>, deactivatePictureInPicture: ActionSlot, bringBackControllerForPictureInPictureDeactivation: @escaping (@escaping () -> Void) -> Void, @@ -53,6 +55,7 @@ public final class MediaStreamVideoComponent: Component { self.isAdmin = isAdmin self.peerTitle = peerTitle self.videoLoading = videoLoading + self.enablePictureInPicture = enablePictureInPicture self.activatePictureInPicture = activatePictureInPicture self.deactivatePictureInPicture = deactivatePictureInPicture self.bringBackControllerForPictureInPictureDeactivation = bringBackControllerForPictureInPictureDeactivation @@ -90,6 +93,9 @@ public final class MediaStreamVideoComponent: Component { if lhs.videoLoading != rhs.videoLoading { return false } + if lhs.enablePictureInPicture != rhs.enablePictureInPicture { + return false + } return true } @@ -349,7 +355,7 @@ public final class MediaStreamVideoComponent: Component { UIView.animate(withDuration: 0.3) { videoView.alpha = 1 } - if let sampleBufferVideoView = videoView as? SampleBufferVideoRenderingView { + if component.enablePictureInPicture, let sampleBufferVideoView = videoView as? SampleBufferVideoRenderingView { sampleBufferVideoView.sampleBufferLayer.masksToBounds = true if #available(iOS 13.0, *) { diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift index a4959ce403..00f47e3a18 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemContentComponent.swift @@ -1000,6 +1000,7 @@ final class StoryItemContentComponent: Component { isFullscreen: false, videoLoading: false, callPeer: nil, + enablePictureInPicture: false, activatePictureInPicture: ActionSlot(), deactivatePictureInPicture: ActionSlot(), bringBackControllerForPictureInPictureDeactivation: { f in diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 6ac61a8a86..979dbb1d07 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -951,6 +951,9 @@ public final class StoryItemSetContainerComponent: Component { view.deactivateInput() if self.sendMessageContext.inputMediaNode != nil { self.state?.updated(transition: .spring(duration: 0.4).withUserData(TextFieldComponent.AnimationHint(view: nil, kind: .textFocusChanged(isFocused: false)))) + DispatchQueue.main.async { [weak self] in + self?.state?.updated(transition: .spring(duration: 0.4).withUserData(TextFieldComponent.AnimationHint(view: nil, kind: .textFocusChanged(isFocused: false)))) + } } } else { self.state?.updated(transition: .spring(duration: 0.4).withUserData(TextFieldComponent.AnimationHint(view: nil, kind: .textFocusChanged(isFocused: false))))