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:
Joshua Goins
2025-07-15 14:44:23 -04:00
parent 9ff942915a
commit 34f2c2dabc
2 changed files with 10 additions and 11 deletions

View File

@@ -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();
}

View File

@@ -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.