diff options
-rw-r--r-- | src/timeline/TimelineModel.cpp | 21 | ||||
-rw-r--r-- | src/timeline/TimelineModel.h | 3 |
2 files changed, 10 insertions, 14 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index ab0e3aef..96fc5aca 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -740,8 +740,10 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r } else if constexpr (t == mtx::events::EventType::RoomPinnedEvents) return tr("%1 changed the pinned messages.") .arg(displayName(QString::fromStdString(e.sender))); + else if constexpr (t == mtx::events::EventType::RoomJoinRules) + return formatJoinRuleEvent(e); else if constexpr (t == mtx::events::EventType::ImagePackInRoom) - formatImagePackEvent(e); + return formatImagePackEvent(e); else if constexpr (t == mtx::events::EventType::RoomCanonicalAlias) return tr("%1 changed the addresses for this room.") .arg(displayName(QString::fromStdString(e.sender))); @@ -2321,20 +2323,13 @@ TimelineModel::formatTypingUsers(const QStringList &users, const QColor &bg) } QString -TimelineModel::formatJoinRuleEvent(const QString &id) +TimelineModel::formatJoinRuleEvent( + const mtx::events::StateEvent<mtx::events::state::JoinRules> &event) const { - auto e = events.get(id.toStdString(), ""); - if (!e) - return {}; - - auto event = std::get_if<mtx::events::StateEvent<mtx::events::state::JoinRules>>(e); - if (!event) - return {}; - - QString user = QString::fromStdString(event->sender); + QString user = QString::fromStdString(event.sender); QString name = utils::replaceEmoji(displayName(user)); - switch (event->content.join_rule) { + switch (event.content.join_rule) { case mtx::events::state::JoinRule::Public: return tr("%1 opened the room to the public.").arg(name); case mtx::events::state::JoinRule::Invite: @@ -2343,7 +2338,7 @@ TimelineModel::formatJoinRuleEvent(const QString &id) return tr("%1 allowed to join this room by knocking.").arg(name); case mtx::events::state::JoinRule::Restricted: { QStringList rooms; - for (const auto &r : event->content.allow) { + for (const auto &r : event.content.allow) { if (r.type == mtx::events::state::JoinAllowanceType::RoomMembership) rooms.push_back(QString::fromStdString(r.room_id)); } diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index cb500270..08c776f8 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -311,7 +311,8 @@ public: Q_INVOKABLE void joinReplacementRoom(const QString &id); Q_INVOKABLE QString formatMemberEvent(const mtx::events::StateEvent<mtx::events::state::Member> &event) const; - Q_INVOKABLE QString formatJoinRuleEvent(const QString &id); + QString + formatJoinRuleEvent(const mtx::events::StateEvent<mtx::events::state::JoinRules> &event) const; QString formatHistoryVisibilityEvent( const mtx::events::StateEvent<mtx::events::state::HistoryVisibility> &event) const; QString |