Skip image context actions for not-loaded photos.

This commit is contained in:
John Preston 2021-02-04 19:26:49 +04:00
parent a2187a1d2b
commit 11b965e82e
2 changed files with 18 additions and 12 deletions

View File

@ -1088,12 +1088,15 @@ void InnerWidget::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
}
if (lnkPhoto) {
const auto photo = lnkPhoto->photo();
_menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
savePhotoToFile(photo);
}));
_menu->addAction(tr::lng_context_copy_image(tr::now), [=] {
copyContextImage(photo);
});
const auto media = photo->activeMediaView();
if (!photo->isNull() && media && media->loaded()) {
_menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
savePhotoToFile(photo);
}));
_menu->addAction(tr::lng_context_copy_image(tr::now), [=] {
copyContextImage(photo);
});
}
if (photo->hasAttachedStickers()) {
const auto controller = _controller;
auto callback = [=] {

View File

@ -1579,12 +1579,15 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
}
};
const auto addPhotoActions = [&](not_null<PhotoData*> photo) {
_menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
savePhotoToFile(photo);
}));
_menu->addAction(tr::lng_context_copy_image(tr::now), [=] {
copyContextImage(photo);
});
const auto media = photo->activeMediaView();
if (!photo->isNull() && media && media->loaded()) {
_menu->addAction(tr::lng_context_save_image(tr::now), App::LambdaDelayed(st::defaultDropdownMenu.menu.ripple.hideDuration, this, [=] {
savePhotoToFile(photo);
}));
_menu->addAction(tr::lng_context_copy_image(tr::now), [=] {
copyContextImage(photo);
});
}
if (photo->hasAttachedStickers()) {
_menu->addAction(tr::lng_context_attached_stickers(tr::now), [=] {
session->api().attachedStickers().requestAttachedStickerSets(