Show a room preview in the join confirmation dialog
Requires MSC3266 Fixes #1129
This commit is contained in:
parent
213a28eee3
commit
9d8d6b4bca
13 changed files with 355 additions and 27 deletions
54
src/ui/RoomSummary.cpp
Normal file
54
src/ui/RoomSummary.cpp
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
||||
//
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "RoomSummary.h"
|
||||
|
||||
#include <QMetaType>
|
||||
|
||||
#include "ChatPage.h"
|
||||
#include "MatrixClient.h"
|
||||
|
||||
RoomSummary::RoomSummary(std::string roomIdOrAlias_,
|
||||
std::vector<std::string> vias_,
|
||||
QString r_,
|
||||
QObject *p)
|
||||
: QObject(p)
|
||||
, roomIdOrAlias(std::move(roomIdOrAlias_))
|
||||
, vias(std::move(vias_))
|
||||
, reason_(std::move(r_))
|
||||
{
|
||||
auto ctx = std::make_shared<RoomSummaryProxy>();
|
||||
|
||||
connect(ctx.get(), &RoomSummaryProxy::failed, this, [this]() {
|
||||
loaded_ = true;
|
||||
emit loaded();
|
||||
});
|
||||
connect(
|
||||
ctx.get(), &RoomSummaryProxy::loaded, this, [this](const mtx::responses::PublicRoom &resp) {
|
||||
loaded_ = true;
|
||||
room = resp;
|
||||
emit loaded();
|
||||
});
|
||||
|
||||
http::client()->get_summary(
|
||||
roomIdOrAlias,
|
||||
[proxy = std::move(ctx)](const mtx::responses::PublicRoom &room, mtx::http::RequestErr e) {
|
||||
if (e) {
|
||||
emit proxy->failed();
|
||||
} else {
|
||||
emit proxy->loaded(room);
|
||||
}
|
||||
},
|
||||
vias);
|
||||
}
|
||||
|
||||
void
|
||||
RoomSummary::join()
|
||||
{
|
||||
if (isKnockOnly())
|
||||
ChatPage::instance()->knockRoom(
|
||||
QString::fromStdString(roomIdOrAlias), vias, reason_, false, false);
|
||||
else
|
||||
ChatPage::instance()->joinRoomVia(roomIdOrAlias, vias, false, reason_);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue