mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
Don't count m.room.member or m.room.reaction events as viewable
This commit is contained in:
parent
81d3bd8ce6
commit
fef7cd5b83
2 changed files with 34 additions and 2 deletions
|
@ -150,10 +150,16 @@ private:
|
|||
void updateLastSender(const QString &user_id, TimelineDirection direction);
|
||||
void notifyForLastEvent();
|
||||
void notifyForLastEvent(const TimelineEvent &event);
|
||||
|
||||
TimelineEvent findFirstViewableEvent(const std::vector<TimelineEvent> &events);
|
||||
TimelineEvent findLastViewableEvent(const std::vector<TimelineEvent> &events);
|
||||
|
||||
void readLastEvent() const;
|
||||
bool isScrollbarActivated() { return scroll_area_->verticalScrollBar()->value() != 0; }
|
||||
QString getLastEventId() const;
|
||||
QString getEventSender(const mtx::events::collections::TimelineEvents &event) const;
|
||||
mtx::events::EventType getEventType(
|
||||
const mtx::events::collections::TimelineEvents &event) const;
|
||||
|
||||
template<class Event, class Widget>
|
||||
TimelineItem *processMessageEvent(const Event &event, TimelineDirection direction);
|
||||
|
|
|
@ -170,7 +170,7 @@ TimelineView::addBackwardsEvents(const QString &room_id, const mtx::responses::M
|
|||
// is the first batch of messages received through /messages
|
||||
// i.e there are no other messages currently present.
|
||||
if (!topMessages_.empty() && scroll_layout_->count() == 1)
|
||||
notifyForLastEvent(topMessages_.at(0));
|
||||
notifyForLastEvent(findFirstViewableEvent(topMessages_));
|
||||
|
||||
if (isVisible()) {
|
||||
renderTopEvents(topMessages_);
|
||||
|
@ -313,7 +313,7 @@ TimelineView::addEvents(const mtx::responses::Timeline &timeline)
|
|||
bottomMessages_.push_back(e);
|
||||
|
||||
if (!bottomMessages_.empty())
|
||||
notifyForLastEvent(bottomMessages_[bottomMessages_.size() - 1]);
|
||||
notifyForLastEvent(findLastViewableEvent(bottomMessages_));
|
||||
|
||||
// If the current timeline is open and there are messages to be rendered.
|
||||
if (isVisible() && !bottomMessages_.empty()) {
|
||||
|
@ -755,3 +755,29 @@ TimelineView::relativeWidget(TimelineItem *item, int dt) const
|
|||
|
||||
return isOutOfBounds ? nullptr : scroll_layout_->itemAt(pos)->widget();
|
||||
}
|
||||
|
||||
TimelineEvent
|
||||
TimelineView::findFirstViewableEvent(const std::vector<TimelineEvent> &events)
|
||||
{
|
||||
auto it = std::find_if(events.begin(), events.end(), [this](const auto &event) {
|
||||
return mtx::events::EventType::RoomMessage == getEventType(event);
|
||||
});
|
||||
|
||||
return (it == std::end(events)) ? events.front() : *it;
|
||||
}
|
||||
|
||||
TimelineEvent
|
||||
TimelineView::findLastViewableEvent(const std::vector<TimelineEvent> &events)
|
||||
{
|
||||
auto it = std::find_if(events.rbegin(), events.rend(), [this](const auto &event) {
|
||||
return mtx::events::EventType::RoomMessage == getEventType(event);
|
||||
});
|
||||
|
||||
return (it == std::rend(events)) ? events.back() : *it;
|
||||
}
|
||||
|
||||
inline mtx::events::EventType
|
||||
TimelineView::getEventType(const mtx::events::collections::TimelineEvents &event) const
|
||||
{
|
||||
return mpark::visit([](auto msg) { return msg.type; }, event);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue