diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-04-03 20:08:48 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-04-03 20:08:48 +0900 |
commit | 7508887564935f70b086ed6fe79bd86757d1fc38 (patch) | |
tree | 9f7d3c6db59009ecafd50b08e54dfc68ffac0dd1 /lib/room.cpp | |
parent | 27386af703974154256cf755712bb46099500847 (diff) | |
download | libquotient-7508887564935f70b086ed6fe79bd86757d1fc38.tar.gz libquotient-7508887564935f70b086ed6fe79bd86757d1fc38.zip |
Room::postFile: initiate uploading the file even before adding a pending event
This is to make sure a pending event with file transfer already placed.
Diffstat (limited to 'lib/room.cpp')
-rw-r--r-- | lib/room.cpp | 11 |
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) { |