Skip to content
Snippets Groups Projects
Verified Commit 242f61c8 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Fix state event rendering for join rules and emojis

parent eb2c87f0
No related branches found
No related tags found
No related merge requests found
Pipeline #5312 passed
......@@ -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));
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment