Preserve failed composer drafts and cancel PM submissions with a result
This commit is contained in:
1 parent
d82b521a4f
commit
090724bbde
3 files changed
+41
-10
No files matched your search
@@ -279,7 +279,7 @@ bool InputBar::submissionPending() const {
|
||||
/* Канальный текст и каждая часть ответа имеют собственное подтверждение и снимок черновика. */
|
||||
quint64 InputBar::beginSubmission(const QByteArray& reply, quint64 generation, const QString& target,
|
||||
const QString& text, const QString& source) {
|
||||
if (reply.isEmpty() && (m_dmMode || text.isEmpty())) return 0;
|
||||
if (reply.isEmpty() && text.isEmpty()) return 0;
|
||||
const quint64 request = ++s_submissionSequence;
|
||||
m_pendingSubmissions.insert(request, {generation, target, text, source, m_input->document()->revision(), m_attachmentRevision});
|
||||
GUI_DEBUG("send: pending ch=%s reply=%s request=%llu", qPrintable(target), reply.toHex().constData(), (unsigned long long)request);
|
||||
@@ -287,6 +287,11 @@ quint64 InputBar::beginSubmission(const QByteArray& reply, quint64 generation, c
|
||||
}
|
||||
|
||||
void InputBar::submissionResult(quint64 request, bool success) {
|
||||
if (!request && !success) {
|
||||
m_submissionFailed = true;
|
||||
GUI_ERROR("send: untracked attachment rejected target=%s", qPrintable(m_channelIdForRecord));
|
||||
emit attachmentRejected(QCoreApplication::translate("ChatGui", "Could not send message. Please try again.")); return;
|
||||
}
|
||||
if (request && request == m_editRequest) {
|
||||
m_editRequest = 0; m_input->setReadOnly(false);
|
||||
if (success) cancelEdit();
|
||||
@@ -515,13 +520,14 @@ void InputBar::onSendClicked() {
|
||||
emit sendFileAttachment(target, attachmentSource, attachmentDestination, attachmentName, reply, requestId);
|
||||
}
|
||||
if (!alive || context != m_attachmentContext) return;
|
||||
if (m_submissionFailed) return;
|
||||
if (reply.isEmpty()) clearPendingAttachment();
|
||||
}
|
||||
if (!text.isEmpty()) {
|
||||
const quint64 request = beginSubmission(reply, m_replyGeneration, m_channelIdForRecord, text);
|
||||
emit sendMessage(text, reply, request);
|
||||
if (!alive || context != m_attachmentContext) return;
|
||||
if (!request) m_input->clear();
|
||||
if (!request && !m_submissionFailed) m_input->clear();
|
||||
if (m_emojiPanel) m_emojiPanel->hide();
|
||||
m_input->setFocus();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user