Use one owned channel submission path and preserve the emitting context

This commit is contained in:
evgeny committed 2026-10-28 00:58:59 +01:00
1 parent 195b9c5afb
commit 45485f4fbc
2 files changed
+12 -10

No files matched your search

+10 -6
View File
@@ -457,6 +457,9 @@ void InputBar::onSendClicked() {
GUI_WARN("send: submission still pending ch=%s", qPrintable(m_channelIdForRecord)); return;
}
m_submissionFailed = false;
QPointer<InputBar> alive(this);
const quint64 context = m_attachmentContext;
const QString target = m_channelIdForRecord;
const QByteArray reply = m_replyTo;
QString text = m_input->toPlainText();
while (!text.isEmpty() && (text.back() == ' ' || text.back() == '\t'))
@@ -466,6 +469,7 @@ void InputBar::onSendClicked() {
if (!hasAttach && text.isEmpty()) return;
if (hasAttach) {
const QString source = m_pendingAttachSrc, destination = m_pendingAttachDest, name = m_pendingAttachName;
const quint64 requestId = beginSubmission(reply, m_replyGeneration, m_channelIdForRecord, {}, m_pendingAttachSrc);
const bool encrypted = !m_dmMode && m_encryptCheck->isChecked();
if (encrypted) {
@@ -487,10 +491,10 @@ void InputBar::onSendClicked() {
snprintf(request->info.name, sizeof(request->info.name), "%s", name.constData());
if (reply.size() == 32) memcpy(request->reply_to, reply.constData(), 32);
request->request_id = requestId;
emit submitAttachment(m_channelIdForRecord, request);
emit submitAttachment(target, request);
} else if (m_pendingAttachAsImage) {
GUI_INFO("send: image=%s name=%s", qPrintable(m_pendingAttachSrc), qPrintable(m_pendingAttachName));
emit sendImageAttachment(m_channelIdForRecord, m_pendingAttachSrc, m_pendingAttachDest, m_pendingAttachName, reply, requestId);
emit sendImageAttachment(target, source, destination, name, reply, requestId);
} else if (m_pendingAttachAsVideo) {
GUI_INFO("send: video=%s name=%s", qPrintable(m_pendingAttachSrc), qPrintable(m_pendingAttachName));
auto* request = (struct attachment_send_req*)u_calloc(1, sizeof(struct attachment_send_req));
@@ -505,18 +509,18 @@ void InputBar::onSendClicked() {
request->request_id = requestId;
snprintf(request->source, sizeof(request->source), "%s", source.constData());
snprintf(request->info.name, sizeof(request->info.name), "%s", name.constData());
emit submitAttachment(m_channelIdForRecord, request);
emit submitAttachment(target, request);
} else {
GUI_INFO("send: file=%s name=%s", qPrintable(m_pendingAttachSrc), qPrintable(m_pendingAttachName));
emit sendFileAttachment(m_channelIdForRecord, m_pendingAttachSrc, m_pendingAttachDest, m_pendingAttachName, reply, requestId);
emit sendFileAttachment(target, source, destination, name, reply, requestId);
}
if (!alive || context != m_attachmentContext) return;
if (reply.isEmpty()) clearPendingAttachment();
}
if (!text.isEmpty()) {
const quint64 request = beginSubmission(reply, m_replyGeneration, m_channelIdForRecord, text);
QPointer<InputBar> alive(this);
emit sendMessage(text, reply, request);
if (!alive) return;
if (!alive || context != m_attachmentContext) return;
if (!request) m_input->clear();
if (m_emojiPanel) m_emojiPanel->hide();
m_input->setFocus();