From 4db2505f5d5d1a14c010932748fdf6b9e1804ab3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 5 Oct 2020 18:26:27 +0300 Subject: [PATCH] Fix deleting profile photos. Fixes #8720. --- .../media/view/media_view_overlay_widget.cpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp index 3984ad86b..692386237 100644 --- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp +++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp @@ -1489,32 +1489,33 @@ void OverlayWidget::onForward() { } void OverlayWidget::onDelete() { - const auto session = _session; - if (!session) { + if (!_session) { return; } - close(); - const auto deletingPeerPhoto = [this] { + const auto session = _session; + const auto photo = _photo; + const auto msgid = _msgid; + const auto deletingPeerPhoto = [&] { if (!_msgid) { return true; - } - if (_photo && _history) { + } else if (_photo && _history) { if (_history->peer->userpicPhotoId() == _photo->id) { return _firstOpenedPeerPhoto; } } return false; - }; + }(); + close(); - Core::App().domain().activate(&_session->account()); - const auto &active = _session->windows(); + Core::App().domain().activate(&session->account()); + const auto &active = session->windows(); if (active.empty()) { return; } - if (deletingPeerPhoto()) { - active.front()->content()->deletePhotoLayer(_photo); - } else if (const auto item = session->data().message(_msgid)) { + if (deletingPeerPhoto) { + active.front()->content()->deletePhotoLayer(photo); + } else if (const auto item = session->data().message(msgid)) { const auto suggestModerateActions = true; Ui::show(Box(item, suggestModerateActions)); }