Set preview as cancelled if no preview in editing message.

This commit is contained in:
John Preston 2021-01-27 20:25:45 +04:00
parent 61f6851486
commit dd401a063b
2 changed files with 21 additions and 10 deletions

View File

@ -1327,7 +1327,7 @@ void HistoryWidget::fieldChanged() {
} }
updateSendButtonType(); updateSendButtonType();
if (showRecordButton()) { if (!HasSendText(_field)) {
_previewCancelled = false; _previewCancelled = false;
} }
if (updateCmdStartShown()) { if (updateCmdStartShown()) {
@ -5682,19 +5682,23 @@ void HistoryWidget::editMessage(not_null<HistoryItem*> item) {
editData.text.size(), editData.text.size(),
QFIXED_MAX QFIXED_MAX
}; };
const auto previewPage = [&]() -> WebPageData* {
if (const auto media = item->media()) {
return media->webpage();
}
return nullptr;
}();
const auto previewCancelled = !previewPage;
_history->setLocalEditDraft(std::make_unique<Data::Draft>( _history->setLocalEditDraft(std::make_unique<Data::Draft>(
editData, editData,
item->id, item->id,
cursor, cursor,
false)); previewCancelled));
applyDraft(); applyDraft();
_previewData = nullptr; _previewData = previewPage;
if (const auto media = item->media()) { if (_previewData) {
if (const auto page = media->webpage()) { updatePreview();
_previewData = page;
updatePreview();
}
} }
updateBotKeyboard(); updateBotKeyboard();

View File

@ -1223,7 +1223,7 @@ void ComposeControls::fieldChanged() {
_sendActionUpdates.fire({ Api::SendProgressType::Typing }); _sendActionUpdates.fire({ Api::SendProgressType::Typing });
} }
updateSendButtonType(); updateSendButtonType();
if (showRecordButton()) { if (!HasSendText(_field)) {
_previewCancelled = false; _previewCancelled = false;
} }
if (updateBotCommandShown()) { if (updateBotCommandShown()) {
@ -1831,13 +1831,20 @@ void ComposeControls::editMessage(not_null<HistoryItem*> item) {
editData.text.size(), editData.text.size(),
QFIXED_MAX QFIXED_MAX
}; };
const auto previewPage = [&]() -> WebPageData* {
if (const auto media = item->media()) {
return media->webpage();
}
return nullptr;
}();
const auto previewCancelled = !previewPage;
_history->setDraft( _history->setDraft(
draftKey(DraftType::Edit), draftKey(DraftType::Edit),
std::make_unique<Data::Draft>( std::make_unique<Data::Draft>(
editData, editData,
item->id, item->id,
cursor, cursor,
false)); previewCancelled));
applyDraft(); applyDraft();
if (_autocomplete) { if (_autocomplete) {