summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-12-13 05:08:05 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-12-13 05:08:22 +0100
commit952827d629bbb7571f290dad63ae5dad69646472 (patch)
treed07ccc332da509ff870c9ad5f9ff56883ccd8efe /src
parentDisable keyboard selection for text by default (diff)
downloadnheko-952827d629bbb7571f290dad63ae5dad69646472.tar.xz
Add a button to room the upgraded room in the timeline
Diffstat (limited to 'src')
-rw-r--r--src/timeline/TimelineModel.cpp27
-rw-r--r--src/timeline/TimelineModel.h1
2 files changed, 27 insertions, 1 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index fe8a78ef..62dbdae6 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -1489,7 +1489,6 @@ TimelineModel::sendEncryptedMessage(mtx::events::RoomEvent<T> msg, mtx::events:: const auto room_id = room_id_.toStdString(); using namespace mtx::events; - using namespace mtx::identifiers; nlohmann::json doc = {{"type", mtx::events::to_string(eventType)}, {"content", nlohmann::json(msg.content)}, @@ -2658,6 +2657,32 @@ TimelineModel::showAcceptKnockButton(const QString &id) return event->content.membership == Membership::Knock; } +void +TimelineModel::joinReplacementRoom(const QString &id) +{ + mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), ""); + if (!e) + return; + + auto event = std::get_if<mtx::events::StateEvent<mtx::events::state::Tombstone>>(e); + if (!event) + return; + + auto joined_rooms = cache::joinedRooms(); + for (const auto &roomid : joined_rooms) { + if (roomid == event->content.replacement_room) { + manager_->rooms()->setCurrentRoom( + QString::fromStdString(event->content.replacement_room)); + return; + } + } + + ChatPage::instance()->joinRoomVia( + event->content.replacement_room, + {mtx::identifiers::parse<mtx::identifiers::User>(event->sender).hostname()}, + true); +} + QString TimelineModel::formatMemberEvent(const QString &id) { diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index 2352be1f..01d80797 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h
@@ -287,6 +287,7 @@ public: Q_INVOKABLE QString formatTypingUsers(const std::vector<QString> &users, const QColor &bg); Q_INVOKABLE bool showAcceptKnockButton(const QString &id); Q_INVOKABLE void acceptKnock(const QString &id); + Q_INVOKABLE void joinReplacementRoom(const QString &id); Q_INVOKABLE QString formatMemberEvent(const QString &id); Q_INVOKABLE QString formatJoinRuleEvent(const QString &id); Q_INVOKABLE QString formatHistoryVisibilityEvent(const QString &id);