Try to fix duplicate messages in certain edge cases (i.e. sync and pagination at the same time)
This commit is contained in:
parent
f260b8b4ae
commit
4efac5a247
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user