Stop a room's lastActiveTime from changing because of hidden events
This was just a missed oversight during the refactoring, we need to pass the hidden filter into NeoChatRoom::lastEvent so it doesn't pick up on hidden events and push rooms to the top for no discernible reason. Also, I simplified the function to take out the cached event handling, because lastEvent is already doing that. The function is const now, too and has some nicer comments.
This commit is contained in:
@@ -441,20 +441,19 @@ void NeoChatRoom::onRedaction(const RoomEvent &prevEvent, const RoomEvent & /*af
|
||||
}
|
||||
}
|
||||
|
||||
QDateTime NeoChatRoom::lastActiveTime()
|
||||
QDateTime NeoChatRoom::lastActiveTime() const
|
||||
{
|
||||
if (timelineSize() == 0) {
|
||||
if (m_cachedEvent != nullptr) {
|
||||
return m_cachedEvent->originTimestamp();
|
||||
}
|
||||
return QDateTime();
|
||||
}
|
||||
|
||||
if (auto event = lastEvent()) {
|
||||
// Find the last relevant event:
|
||||
if (const auto event = lastEvent(m_hiddenFilter)) {
|
||||
return event->originTimestamp();
|
||||
}
|
||||
|
||||
// no message found, take last event
|
||||
// If nothing is loaded yet, and there is no cached event:
|
||||
if (timelineSize() == 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// No message found, take last event:
|
||||
return messageEvents().rbegin()->get()->originTimestamp();
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
bool visible() const;
|
||||
void setVisible(bool visible);
|
||||
|
||||
[[nodiscard]] QDateTime lastActiveTime();
|
||||
[[nodiscard]] QDateTime lastActiveTime() const;
|
||||
|
||||
/**
|
||||
* @brief Get the last interesting event.
|
||||
|
||||
Reference in New Issue
Block a user