Fix deleting profile photos.

Fixes #8720.
This commit is contained in:
John Preston 2020-10-05 18:26:27 +03:00
parent 4d40336be0
commit 4db2505f5d

View file

@ -1489,32 +1489,33 @@ void OverlayWidget::onForward() {
} }
void OverlayWidget::onDelete() { void OverlayWidget::onDelete() {
const auto session = _session; if (!_session) {
if (!session) {
return; return;
} }
close(); const auto session = _session;
const auto deletingPeerPhoto = [this] { const auto photo = _photo;
const auto msgid = _msgid;
const auto deletingPeerPhoto = [&] {
if (!_msgid) { if (!_msgid) {
return true; return true;
} } else if (_photo && _history) {
if (_photo && _history) {
if (_history->peer->userpicPhotoId() == _photo->id) { if (_history->peer->userpicPhotoId() == _photo->id) {
return _firstOpenedPeerPhoto; return _firstOpenedPeerPhoto;
} }
} }
return false; return false;
}; }();
close();
Core::App().domain().activate(&_session->account()); Core::App().domain().activate(&session->account());
const auto &active = _session->windows(); const auto &active = session->windows();
if (active.empty()) { if (active.empty()) {
return; return;
} }
if (deletingPeerPhoto()) { if (deletingPeerPhoto) {
active.front()->content()->deletePhotoLayer(_photo); active.front()->content()->deletePhotoLayer(photo);
} else if (const auto item = session->data().message(_msgid)) { } else if (const auto item = session->data().message(msgid)) {
const auto suggestModerateActions = true; const auto suggestModerateActions = true;
Ui::show(Box<DeleteMessagesBox>(item, suggestModerateActions)); Ui::show(Box<DeleteMessagesBox>(item, suggestModerateActions));
} }