2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-18 13:59:46 +00:00

Improve editing messages with link previews.

Now preview state can be one of (allowed, cancelled, empty-in-edit).

In case of editing a message without preview we set the state to
empty-in-edit and it changes to allowed if the links in the message
are changed somehow.

That way we don't need to cancel the preview when editing a message
with a cancelled preview and at the same time adding a link to
a message that had no preview in the first place will add a preview.
This commit is contained in:
John Preston
2021-01-29 15:27:17 +04:00
parent fc4ed2ff91
commit 8f0e23bb25
16 changed files with 159 additions and 82 deletions

View File

@@ -18,32 +18,29 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
namespace Data {
namespace {
} // namespace
Draft::Draft(
const TextWithTags &textWithTags,
MsgId msgId,
const MessageCursor &cursor,
bool previewCancelled,
PreviewState previewState,
mtpRequestId saveRequestId)
: textWithTags(textWithTags)
, msgId(msgId)
, cursor(cursor)
, previewCancelled(previewCancelled)
, previewState(previewState)
, saveRequestId(saveRequestId) {
}
Draft::Draft(
not_null<const Ui::InputField*> field,
MsgId msgId,
bool previewCancelled,
PreviewState previewState,
mtpRequestId saveRequestId)
: textWithTags(field->getTextWithTags())
, msgId(msgId)
, cursor(field)
, previewCancelled(previewCancelled) {
, previewState(previewState) {
}
void ApplyPeerCloudDraft(
@@ -66,7 +63,9 @@ void ApplyPeerCloudDraft(
textWithTags,
replyTo,
MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX),
draft.is_no_webpage());
(draft.is_no_webpage()
? Data::PreviewState::Cancelled
: Data::PreviewState::Allowed));
cloudDraft->date = draft.vdate().v;
history->setCloudDraft(std::move(cloudDraft));