aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index a20c1cf0..1a63866f 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -1533,12 +1533,17 @@ QString Room::postFile(const QString& plainText, const QUrl& localPath,
{
QFileInfo localFile { localPath.toLocalFile() };
Q_ASSERT(localFile.isFile());
+
+ const auto txnId = connection()->generateTxnId();
// Remote URL will only be known after upload; fill in the local path
// to enable the preview while the event is pending.
- const auto txnId = d->addAsPending(makeEvent<RoomMessageEvent>(
- plainText, localFile, asGenericFile)
- )->transactionId();
uploadFile(txnId, localPath);
+ {
+ auto&& event =
+ makeEvent<RoomMessageEvent>(plainText, localFile, asGenericFile);
+ event->setTransactionId(txnId);
+ d->addAsPending(std::move(event));
+ }
auto* context = new QObject(this);
connect(this, &Room::fileTransferCompleted, context,
[context,this,txnId] (const QString& id, QUrl, const QUrl& mxcUri) {