diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-10 08:31:43 +0200 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2020-06-10 15:06:47 +0200 |
commit | f3b8dbe01a43c5334a371edda833173468d99dc4 (patch) | |
tree | 8121a01d4a1df5b84377cb5a33f213af861ab753 /lib | |
parent | 08f4490d4d770878f805d26bfe1d0ef9cb3f7393 (diff) | |
download | libquotient-f3b8dbe01a43c5334a371edda833173468d99dc4.tar.gz libquotient-f3b8dbe01a43c5334a371edda833173468d99dc4.zip |
Room: fix messageSent() being emitted too early
Closes #406.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/room.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 23e07cae..22ec1c82 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1565,18 +1565,17 @@ QString Room::Private::doSendEvent(const RoomEvent* pEvent) std::bind(&Room::Private::onEventSendingFailure, this, txnId, call)); Room::connect(call, &BaseJob::success, q, [this, call, txnId] { - emit q->messageSent(txnId, call->eventId()); auto it = q->findPendingEvent(txnId); - if (it == unsyncedEvents.end()) { + if (it != unsyncedEvents.end()) { + if (it->deliveryStatus() != EventStatus::ReachedServer) { + it->setReachedServer(call->eventId()); + emit q->pendingEventChanged(int(it - unsyncedEvents.begin())); + } + } else qCDebug(EVENTS) << "Pending event for transaction" << txnId << "already merged"; - return; - } - if (it->deliveryStatus() != EventStatus::ReachedServer) { - it->setReachedServer(call->eventId()); - emit q->pendingEventChanged(int(it - unsyncedEvents.begin())); - } + emit q->messageSent(txnId, call->eventId()); }); } else onEventSendingFailure(txnId); |