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:11:41 +0900 |
commit | 8035ec464ce797abab5e464c2cfb485f7fa14d06 (patch) | |
tree | 30b9587da0836389a8dcced9a4dd0bbf000c6cdf /lib | |
parent | 008207f178475531c0a8a86b2192c09d7134ad0e (diff) | |
download | libquotient-8035ec464ce797abab5e464c2cfb485f7fa14d06.tar.gz libquotient-8035ec464ce797abab5e464c2cfb485f7fa14d06.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')
-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 b64ed3a1..587b598d 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1540,12 +1540,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) { |