summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-06-17 02:29:19 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-06-17 02:29:19 +0300
commit66249ed12628b9bb5cf0603a627858d921e8b41a (patch)
tree7de52c68851a918b3aded214aa5fb9043032dafb /src
parentUpdate CI instructions (diff)
downloadnheko-66249ed12628b9bb5cf0603a627858d921e8b41a.tar.xz
Correctly mark received messages whose response came after /sync
Diffstat (limited to 'src')
-rw-r--r--src/timeline/TimelineItem.cc1
-rw-r--r--src/timeline/TimelineView.cc19
2 files changed, 14 insertions, 6 deletions
diff --git a/src/timeline/TimelineItem.cc b/src/timeline/TimelineItem.cc

index 3505d347..c104801d 100644 --- a/src/timeline/TimelineItem.cc +++ b/src/timeline/TimelineItem.cc
@@ -432,6 +432,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Text> void TimelineItem::markReceived() { + isReceived_ = true; checkmark_->setText(CHECKMARK); checkmark_->setAlignment(Qt::AlignTop); diff --git a/src/timeline/TimelineView.cc b/src/timeline/TimelineView.cc
index 5ee2d32b..e437439e 100644 --- a/src/timeline/TimelineView.cc +++ b/src/timeline/TimelineView.cc
@@ -602,11 +602,18 @@ TimelineView::updatePendingMessage(const std::string &txn_id, const QString &eve if (msg.widget) { msg.widget->setEventId(event_id); - msg.widget->markReceived(); eventIds_[event_id] = msg.widget; - } - pending_sent_msgs_.append(msg); + // If the response comes after we have received the event from sync + // we've already marked the widget as received. + if (!msg.widget->isReceived()) { + msg.widget->markReceived(); + pending_sent_msgs_.append(msg); + } + } else { + nhlog::ui()->warn("[{}] received message response for invalid widget", + txn_id); + } } sendNextPendingMessage(); @@ -809,10 +816,10 @@ TimelineView::removePendingMessage(const std::string &txn_id) } for (auto it = pending_msgs_.begin(); it != pending_msgs_.end(); ++it) { if (it->txn_id == txn_id) { - int index = std::distance(pending_msgs_.begin(), it); - pending_msgs_.removeAt(index); + if (it->widget) + it->widget->markReceived(); - nhlog::ui()->info("[{}] removed message before sync", txn_id); + nhlog::ui()->info("[{}] received sync before message response", txn_id); return; } }