2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +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

@@ -215,13 +215,13 @@ void History::createLocalDraftFromCloud() {
draft->textWithTags,
draft->msgId,
draft->cursor,
draft->previewCancelled));
draft->previewState));
existing = localDraft();
} else if (existing != draft) {
existing->textWithTags = draft->textWithTags;
existing->msgId = draft->msgId;
existing->cursor = draft->cursor;
existing->previewCancelled = draft->previewCancelled;
existing->previewState = draft->previewState;
}
existing->date = draft->date;
}
@@ -280,7 +280,7 @@ Data::Draft *History::createCloudDraft(const Data::Draft *fromDraft) {
TextWithTags(),
0,
MessageCursor(),
false));
Data::PreviewState::Allowed));
cloudDraft()->date = TimeId(0);
} else {
auto existing = cloudDraft();
@@ -289,13 +289,13 @@ Data::Draft *History::createCloudDraft(const Data::Draft *fromDraft) {
fromDraft->textWithTags,
fromDraft->msgId,
fromDraft->cursor,
fromDraft->previewCancelled));
fromDraft->previewState));
existing = cloudDraft();
} else if (existing != fromDraft) {
existing->textWithTags = fromDraft->textWithTags;
existing->msgId = fromDraft->msgId;
existing->cursor = fromDraft->cursor;
existing->previewCancelled = fromDraft->previewCancelled;
existing->previewState = fromDraft->previewState;
}
existing->date = base::unixtime::now();
}