summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-12-06 02:59:15 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-12-06 02:59:15 +0200
commitc1d0bbaf0b3e312b7d2f362173c31a4560d05b58 (patch)
treebb341f6684885d0c696914173724d02ec0bf15e2 /src
parent65a2743bf1071c6d444fe3a429ef0b58c69b5933 (diff)
Prevent queue from getting blocked (#142)
Try sending a message when all the sent messages have been received through /sync.
Diffstat (limited to 'src')
-rw-r--r--src/MatrixClient.cc1
-rw-r--r--src/timeline/TimelineView.cc12
2 files changed, 9 insertions, 4 deletions
diff --git a/src/MatrixClient.cc b/src/MatrixClient.cc
index 28aeb47d..8214cfc5 100644
--- a/src/MatrixClient.cc
+++ b/src/MatrixClient.cc
@@ -300,7 +300,6 @@ MatrixClient::sendRoomMessage(mtx::events::MessageType ty,
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (status == 0 || status >= 400) {
- qWarning() << reply->errorString();
emit messageSendFailed(roomid, txnId);
return;
}
diff --git a/src/timeline/TimelineView.cc b/src/timeline/TimelineView.cc
index 8e9f5f7c..dd51fc52 100644
--- a/src/timeline/TimelineView.cc
+++ b/src/timeline/TimelineView.cc
@@ -372,11 +372,13 @@ TimelineView::addTimelineItem(TimelineItem *item, TimelineDirection direction)
void
TimelineView::updatePendingMessage(int txn_id, QString event_id)
{
- if (pending_msgs_.head().txn_id == txn_id) { // We haven't received it yet
+ if (!pending_msgs_.isEmpty() &&
+ pending_msgs_.head().txn_id == txn_id) { // We haven't received it yet
auto msg = pending_msgs_.dequeue();
msg.event_id = event_id;
pending_sent_msgs_.append(msg);
}
+
sendNextPendingMessage();
}
@@ -405,7 +407,7 @@ void
TimelineView::handleNewUserMessage(PendingMessage msg)
{
pending_msgs_.enqueue(msg);
- if (pending_msgs_.size() == 1 && pending_sent_msgs_.size() == 0)
+ if (pending_msgs_.size() == 1 && pending_sent_msgs_.isEmpty())
sendNextPendingMessage();
}
@@ -474,6 +476,10 @@ TimelineView::removePendingMessage(const QString &txnid)
if (QString::number(it->txn_id) == txnid) {
int index = std::distance(pending_sent_msgs_.begin(), it);
pending_sent_msgs_.removeAt(index);
+
+ if (pending_sent_msgs_.isEmpty())
+ sendNextPendingMessage();
+
return;
}
}
@@ -491,7 +497,7 @@ TimelineView::handleFailedMessage(int txnid)
{
Q_UNUSED(txnid);
// Note: We do this even if the message has already been echoed.
- QTimer::singleShot(500, this, SLOT(sendNextPendingMessage()));
+ QTimer::singleShot(2000, this, SLOT(sendNextPendingMessage()));
}
void