Added a handler for "MESSAGE_EMPTY" error to delete a local message.

- Added a determination of the zero-width-space as the space.
 - Fixes #3145.
This commit is contained in:
23rd 2019-03-09 17:56:11 +03:00 committed by John Preston
parent e174025a92
commit bfc9e43eb4
2 changed files with 6 additions and 2 deletions

View File

@ -4628,7 +4628,11 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
applyUpdates(result, randomId);
history->clearSentDraftText(QString());
}).fail([=](const RPCError &error) {
sendMessageFail(error);
if (error.type() == qstr("MESSAGE_EMPTY")) {
lastMessage->destroy();
} else {
sendMessageFail(error);
}
history->clearSentDraftText(QString());
}).afterRequest(history->sendRequestId
).send();

View File

@ -261,7 +261,7 @@ QString textcmdStopSemibold();
const QChar *textSkipCommand(const QChar *from, const QChar *end, bool canLink = true);
inline bool chIsSpace(QChar ch, bool rich = false) {
return ch.isSpace() || (ch < 32 && !(rich && ch == TextCommand)) || (ch == QChar::ParagraphSeparator) || (ch == QChar::LineSeparator) || (ch == QChar::ObjectReplacementCharacter) || (ch == QChar::CarriageReturn) || (ch == QChar::Tabulation);
return ch.isSpace() || (ch < 32 && !(rich && ch == TextCommand)) || (ch == QChar::ParagraphSeparator) || (ch == QChar::LineSeparator) || (ch == QChar::ObjectReplacementCharacter) || (ch == QChar::CarriageReturn) || (ch == QChar::Tabulation) || (ch == QChar(8203)/*Zero width space.*/);
}
inline bool chIsDiac(QChar ch) { // diac and variation selectors
return (ch.category() == QChar::Mark_NonSpacing) || (ch == 1652) || (ch >= 64606 && ch <= 64611);