Don't insert "data:image.." after image paste cancel.

This commit is contained in:
John Preston 2024-07-04 08:57:41 +04:00
parent b377c02ad3
commit b648548001
4 changed files with 7 additions and 2 deletions

View File

@ -5668,7 +5668,7 @@ bool HistoryWidget::confirmSendingFiles(
cursor.setPosition(position, QTextCursor::KeepAnchor);
}
_field->setTextCursor(cursor);
if (!insertTextOnCancel.isEmpty()) {
if (Ui::InsertTextOnImageCancel(insertTextOnCancel)) {
_field->textCursor().insertText(insertTextOnCancel);
}
}));

View File

@ -3415,7 +3415,7 @@ Fn<void()> ComposeControls::restoreTextCallback(
cursor.setPosition(position, QTextCursor::KeepAnchor);
}
_field->setTextCursor(cursor);
if (!insertTextOnCancel.isEmpty()) {
if (Ui::InsertTextOnImageCancel(insertTextOnCancel)) {
_field->textCursor().insertText(insertTextOnCancel);
}
});

View File

@ -82,6 +82,10 @@ bool CanBeInAlbumType(PreparedFile::Type type, AlbumType album) {
Unexpected("AlbumType in CanBeInAlbumType.");
}
bool InsertTextOnImageCancel(const QString &text) {
return !text.isEmpty() && !text.startsWith(u"data:image"_q);
}
PreparedList PreparedList::Reordered(
PreparedList &&list,
std::vector<int> order) {

View File

@ -88,6 +88,7 @@ struct PreparedFile {
};
[[nodiscard]] bool CanBeInAlbumType(PreparedFile::Type type, AlbumType album);
[[nodiscard]] bool InsertTextOnImageCancel(const QString &text);
struct PreparedList {
enum class Error {