summary refs log tree commit diff
path: root/src/ui/RoomSummary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/RoomSummary.cpp')
-rw-r--r--src/ui/RoomSummary.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/ui/RoomSummary.cpp b/src/ui/RoomSummary.cpp

index da2a547c..6623da10 100644 --- a/src/ui/RoomSummary.cpp +++ b/src/ui/RoomSummary.cpp
@@ -6,6 +6,7 @@ #include <QMetaType> +#include "Cache.h" #include "ChatPage.h" #include "MatrixClient.h" @@ -18,6 +19,38 @@ RoomSummary::RoomSummary(std::string roomIdOrAlias_, , vias(std::move(vias_)) , reason_(std::move(r_)) { + if (roomIdOrAlias.empty()) + return; + + if (roomIdOrAlias[0] == '!') { + auto temp = cache::singleRoomInfo(roomIdOrAlias); + + if (temp.member_count) { + mtx::responses::PublicRoom newInfo{}; + // newInfo.aliases; + // newInfo.canonical_alias = ""; + newInfo.name = temp.name; + newInfo.room_id = roomIdOrAlias; + newInfo.topic = temp.topic; + newInfo.num_joined_members = temp.member_count; + // newInfo.world_readable; + newInfo.guest_can_join = temp.guest_access; + newInfo.avatar_url = temp.avatar_url; + + newInfo.join_rule = temp.join_rule; + newInfo.room_type = temp.is_space ? mtx::events::state::room_type::space : ""; + newInfo.room_version = temp.version; + newInfo.membership = mtx::events::state::Membership::Join; + // newInfo.encryption; + + this->room = std::move(newInfo); + loaded_ = true; + return; + } + + // newInfo.encryption; + } + auto ctx = std::make_shared<RoomSummaryProxy>(); connect(ctx.get(), &RoomSummaryProxy::failed, this, [this]() { @@ -52,3 +85,13 @@ RoomSummary::join() else ChatPage::instance()->joinRoomVia(roomIdOrAlias, vias, false, reason_); } + +void +RoomSummary::promptJoin() +{ + if (isKnockOnly()) + ChatPage::instance()->knockRoom( + QString::fromStdString(roomIdOrAlias), vias, reason_, false, true); + else + ChatPage::instance()->joinRoomVia(roomIdOrAlias, vias, true, reason_); +}