From cabed9587b7d51852963ae5fdd30608be2fce8f8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 30 Dec 2022 14:26:43 +0400 Subject: [PATCH] Close PiP if message with video gets deleted. --- .../media/view/media_view_overlay_widget.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 775213ab88..2c8b2c5631 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -254,6 +254,7 @@ struct OverlayWidget::PipWrap { PipDelegate delegate; Pip wrapped; + rpl::lifetime lifetime; }; OverlayWidget::Streamed::Streamed( @@ -3352,6 +3353,16 @@ void OverlayWidget::switchToPip() { _streamed->instance.shared(), closeAndContinue, [=] { _pip = nullptr; }); + + if (const auto raw = _message) { + raw->history()->owner().itemRemoved( + ) | rpl::filter([=](not_null item) { + return (raw == item); + }) | rpl::start_with_next([=] { + _pip = nullptr; + }, _pip->lifetime); + } + if (isHidden()) { clearBeforeHide(); clearAfterHide();