Skip to content
Snippets Groups Projects
Commit 4efac5a2 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Try to fix duplicate messages in certain edge cases (i.e. sync and pagination at the same time)

parent f260b8b4
No related branches found
No related tags found
No related merge requests found
......@@ -324,10 +324,16 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
QString id =
boost::apply_visitor([](const auto &e) -> QString { return eventId(e); }, e);
if (this->events.contains(id))
continue;
this->events.insert(id, e);
ids.push_back(id);
}
if (ids.empty)
return;
beginInsertRows(QModelIndex(),
static_cast<int>(this->eventOrder.size()),
static_cast<int>(this->eventOrder.size() + ids.size() - 1));
......@@ -372,13 +378,18 @@ TimelineModel::addBackwardsEvents(const mtx::responses::Messages &msgs)
QString id =
boost::apply_visitor([](const auto &e) -> QString { return eventId(e); }, e);
if (this->events.contains(id))
continue;
this->events.insert(id, e);
ids.push_back(id);
}
beginInsertRows(QModelIndex(), 0, static_cast<int>(ids.size() - 1));
this->eventOrder.insert(this->eventOrder.begin(), ids.rbegin(), ids.rend());
endInsertRows();
if (!ids.empty()) {
beginInsertRows(QModelIndex(), 0, static_cast<int>(ids.size() - 1));
this->eventOrder.insert(this->eventOrder.begin(), ids.rbegin(), ids.rend());
endInsertRows();
}
prev_batch_token_ = QString::fromStdString(msgs.end);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment