Correctly mark received messages whose response came after /sync
This commit is contained in:
parent
c0d32ef319
commit
66249ed126
|
@ -193,6 +193,7 @@ public:
|
||||||
QString eventId() const { return event_id_; }
|
QString eventId() const { return event_id_; }
|
||||||
void setEventId(const QString &event_id) { event_id_ = event_id; }
|
void setEventId(const QString &event_id) { event_id_ = event_id; }
|
||||||
void markReceived();
|
void markReceived();
|
||||||
|
bool isReceived() { return isReceived_; };
|
||||||
void setRoomId(QString room_id) { room_id_ = room_id; }
|
void setRoomId(QString room_id) { room_id_ = room_id; }
|
||||||
void sendReadReceipt() const;
|
void sendReadReceipt() const;
|
||||||
|
|
||||||
|
@ -225,6 +226,10 @@ private:
|
||||||
void setupAvatarLayout(const QString &userName);
|
void setupAvatarLayout(const QString &userName);
|
||||||
void setupSimpleLayout();
|
void setupSimpleLayout();
|
||||||
|
|
||||||
|
//! Whether or not the event associated with the widget
|
||||||
|
//! has been acknowledged by the server.
|
||||||
|
bool isReceived_ = false;
|
||||||
|
|
||||||
QString replaceEmoji(const QString &body);
|
QString replaceEmoji(const QString &body);
|
||||||
QString event_id_;
|
QString event_id_;
|
||||||
QString room_id_;
|
QString room_id_;
|
||||||
|
|
|
@ -432,6 +432,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent<mtx::events::msg::Text>
|
||||||
void
|
void
|
||||||
TimelineItem::markReceived()
|
TimelineItem::markReceived()
|
||||||
{
|
{
|
||||||
|
isReceived_ = true;
|
||||||
checkmark_->setText(CHECKMARK);
|
checkmark_->setText(CHECKMARK);
|
||||||
checkmark_->setAlignment(Qt::AlignTop);
|
checkmark_->setAlignment(Qt::AlignTop);
|
||||||
|
|
||||||
|
|
|
@ -602,12 +602,19 @@ TimelineView::updatePendingMessage(const std::string &txn_id, const QString &eve
|
||||||
|
|
||||||
if (msg.widget) {
|
if (msg.widget) {
|
||||||
msg.widget->setEventId(event_id);
|
msg.widget->setEventId(event_id);
|
||||||
msg.widget->markReceived();
|
|
||||||
eventIds_[event_id] = msg.widget;
|
eventIds_[event_id] = msg.widget;
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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);
|
pending_sent_msgs_.append(msg);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
nhlog::ui()->warn("[{}] received message response for invalid widget",
|
||||||
|
txn_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sendNextPendingMessage();
|
sendNextPendingMessage();
|
||||||
}
|
}
|
||||||
|
@ -809,10 +816,10 @@ TimelineView::removePendingMessage(const std::string &txn_id)
|
||||||
}
|
}
|
||||||
for (auto it = pending_msgs_.begin(); it != pending_msgs_.end(); ++it) {
|
for (auto it = pending_msgs_.begin(); it != pending_msgs_.end(); ++it) {
|
||||||
if (it->txn_id == txn_id) {
|
if (it->txn_id == txn_id) {
|
||||||
int index = std::distance(pending_msgs_.begin(), it);
|
if (it->widget)
|
||||||
pending_msgs_.removeAt(index);
|
it->widget->markReceived();
|
||||||
|
|
||||||
nhlog::ui()->info("[{}] removed message before sync", txn_id);
|
nhlog::ui()->info("[{}] received sync before message response", txn_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue