Fix avatar change being rendered as a join

This commit is contained in:
Nicolas Werner 2023-03-09 21:51:22 +01:00
parent d0d33660ba
commit 3b8a1f85e6
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -1122,14 +1122,25 @@ isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallSelectAnswer> &)
// Workaround. We also want to see a room at the top, if we just joined it // Workaround. We also want to see a room at the top, if we just joined it
auto auto
isYourJoin(const mtx::events::StateEvent<mtx::events::state::Member> &e) isYourJoin(const mtx::events::StateEvent<mtx::events::state::Member> &e, EventStore &events)
{ {
return e.content.membership == mtx::events::state::Membership::Join && if (e.content.membership == mtx::events::state::Membership::Join &&
e.state_key == http::client()->user_id().to_string(); e.state_key == http::client()->user_id().to_string() &&
!e.unsigned_data.replaces_state.empty()) {
auto tempPrevEvent = events.get(e.unsigned_data.replaces_state, e.event_id);
if (tempPrevEvent) {
if (auto prevEvent =
std::get_if<mtx::events::StateEvent<mtx::events::state::Member>>(tempPrevEvent)) {
if (prevEvent->content.membership != mtx::events::state::Membership::Join)
return true;
}
}
}
return false;
} }
template<typename T> template<typename T>
auto auto
isYourJoin(const mtx::events::Event<T> &) isYourJoin(const mtx::events::Event<T> &, EventStore &)
{ {
return false; return false;
} }
@ -1153,7 +1164,7 @@ TimelineModel::updateLastMessage()
if (!event) if (!event)
continue; continue;
if (std::visit([](const auto &e) -> bool { return isYourJoin(e); }, *event)) { if (std::visit([this](const auto &e) -> bool { return isYourJoin(e, events); }, *event)) {
auto time = mtx::accessors::origin_server_ts(*event); auto time = mtx::accessors::origin_server_ts(*event);
uint64_t ts = time.toMSecsSinceEpoch(); uint64_t ts = time.toMSecsSinceEpoch();
auto description = auto description =