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

pull/91/head
Nicolas Werner 5 years ago
parent f260b8b4ae
commit 4efac5a247
  1. 11
      src/timeline2/TimelineModel.cpp

@ -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);
}
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…
Cancel
Save