summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-01-14 20:43:35 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-01-14 20:43:35 +0100
commit54a16ae2d7d811a7f2e4454daf398ace8f97170a (patch)
tree7e0197da20723a365437ee23aa2d82045e8ffcc7 /src
parentReduce avatar cache size (diff)
downloadnheko-54a16ae2d7d811a7f2e4454daf398ace8f97170a.tar.xz
Fix duplicate messages in timeline after sending
Diffstat (limited to 'src')
-rw-r--r--src/timeline/TimelineModel.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index eef4ec31..08c29927 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -139,6 +139,17 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
         });
         connect(this, &TimelineModel::messageSent, this, [this](QString txn_id, QString event_id) {
                 pending.removeOne(txn_id);
+
+                // we could have received the message via sync
+                if (events.contains(event_id)) {
+                        int idx = idToIndex(event_id);
+                        if (idx >= 0) {
+                                beginRemoveRows(QModelIndex(), idx, idx);
+                                eventOrder.erase(eventOrder.begin() + idx);
+                                endRemoveRows();
+                        }
+                }
+
                 int idx = idToIndex(txn_id);
                 if (idx < 0) {
                         nhlog::ui()->warn("Sent index out of range");