mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Show room version in settings
This commit is contained in:
parent
5a0a9c96b2
commit
713f9dbe89
11 changed files with 227 additions and 72 deletions
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation>Matrix-ID</translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation>ANMELDEN</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -274,6 +274,14 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -802,6 +810,11 @@ Medien-Größe: %2
|
|||
<source>Internal ID</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -878,7 +891,7 @@ Medien-Größe: %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation>Matrix ID</translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation>ΕΙΣΟΔΟΣ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -274,6 +274,14 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -800,6 +808,11 @@ Media size: %2
|
|||
<source>Internal ID</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -876,7 +889,7 @@ Media size: %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -274,6 +274,14 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -800,6 +808,11 @@ Media size: %2
|
|||
<source>Internal ID</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -876,7 +889,7 @@ Media size: %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation>Identifiant Matrix</translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation>CONNEXION</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -275,6 +275,14 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -803,6 +811,11 @@ Taille du média : %2
|
|||
<source>Internal ID</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -879,7 +892,7 @@ Taille du média : %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation>Matrix-id</translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation>INLOGGEN</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
@ -274,6 +274,14 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -802,6 +810,11 @@ Mediagrootte: %2
|
|||
<source>Internal ID</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -878,7 +891,7 @@ Mediagrootte: %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation>ID Matrixa</translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation>ZALOGUJ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation>Nie odnaleziono wymaganych punktów końcowych. To może nie być serwer Matriksa.</translation>
|
||||
</message>
|
||||
|
@ -274,6 +274,14 @@
|
|||
<translation type="unfinished">Wyloguj</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -802,6 +810,11 @@ Rozmiar multimediów: %2
|
|||
<source>Internal ID</source>
|
||||
<translation>Wewnętrzne ID</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -881,7 +894,7 @@ Rozmiar multimediów: %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation>Идентификатор Matrix</translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation>ВОЙТИ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation>Необходимые конечные точки не найдены. Возможно, это не сервер Matrix.</translation>
|
||||
</message>
|
||||
|
@ -274,6 +274,14 @@
|
|||
<translation type="unfinished">Выйти</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -803,6 +811,11 @@ Media size: %2
|
|||
<source>Internal ID</source>
|
||||
<translation>Внутренний ID</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -880,7 +893,7 @@ Media size: %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
<context>
|
||||
<name>LoginPage</name>
|
||||
<message>
|
||||
<location filename="../../src/LoginPage.cpp" line="+79"/>
|
||||
<location filename="../../src/LoginPage.cpp" line="+80"/>
|
||||
<source>Matrix ID</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
|
@ -167,17 +167,17 @@
|
|||
<translation>登录</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Autodiscovery failed. Received malformed response.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Autodiscovery failed. Unknown error when requesting .well-known.</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+20"/>
|
||||
<location line="+24"/>
|
||||
<source>The required endpoints were not found. Possibly not a Matrix server.</source>
|
||||
<translation>没找到要求的终端。可能不是一个 Matrix 服务器。</translation>
|
||||
</message>
|
||||
|
@ -274,6 +274,14 @@
|
|||
<translation type="unfinished">登出</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfo</name>
|
||||
<message>
|
||||
<location filename="../../src/Cache.cpp" line="+2204"/>
|
||||
<source>no version stored</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>RoomInfoListItem</name>
|
||||
<message>
|
||||
|
@ -802,6 +810,11 @@ Media size: %2
|
|||
<source>Internal ID</source>
|
||||
<translation>内部 ID</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+10"/>
|
||||
<source>Room Version</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Notifications</source>
|
||||
|
@ -879,7 +892,7 @@ Media size: %2
|
|||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+70"/>
|
||||
<location line="+71"/>
|
||||
<source>ESC</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <stdexcept>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QHash>
|
||||
#include <QSettings>
|
||||
|
@ -958,6 +959,7 @@ Cache::saveState(const mtx::responses::Sync &res)
|
|||
updatedInfo.avatar_url =
|
||||
getRoomAvatarUrl(txn, statesdb, membersdb, QString::fromStdString(room.first))
|
||||
.toStdString();
|
||||
updatedInfo.version = getRoomVersion(txn, statesdb).toStdString();
|
||||
|
||||
// Process the account_data associated with this room
|
||||
bool has_new_tags = false;
|
||||
|
@ -1551,6 +1553,32 @@ Cache::getRoomTopic(lmdb::txn &txn, lmdb::dbi &statesdb)
|
|||
return QString();
|
||||
}
|
||||
|
||||
QString
|
||||
Cache::getRoomVersion(lmdb::txn &txn, lmdb::dbi &statesdb)
|
||||
{
|
||||
using namespace mtx::events;
|
||||
using namespace mtx::events::state;
|
||||
|
||||
lmdb::val event;
|
||||
bool res = lmdb::dbi_get(
|
||||
txn, statesdb, lmdb::val(to_string(mtx::events::EventType::RoomCreate)), event);
|
||||
|
||||
if (res) {
|
||||
try {
|
||||
StateEvent<Create> msg =
|
||||
json::parse(std::string(event.data(), event.size()));
|
||||
|
||||
if (!msg.content.room_version.empty())
|
||||
return QString::fromStdString(msg.content.room_version);
|
||||
} catch (const json::exception &e) {
|
||||
nhlog::db()->warn("failed to parse m.room.create event: {}", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
nhlog::db()->warn("m.room.create event is missing room version, assuming version \"1\"");
|
||||
return QString("1");
|
||||
}
|
||||
|
||||
QString
|
||||
Cache::getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb)
|
||||
{
|
||||
|
@ -2148,3 +2176,39 @@ Cache::clearUserColors()
|
|||
{
|
||||
UserColors.clear();
|
||||
}
|
||||
|
||||
void
|
||||
to_json(json &j, const RoomInfo &info)
|
||||
{
|
||||
j["name"] = info.name;
|
||||
j["topic"] = info.topic;
|
||||
j["avatar_url"] = info.avatar_url;
|
||||
j["version"] = info.version;
|
||||
j["is_invite"] = info.is_invite;
|
||||
j["join_rule"] = info.join_rule;
|
||||
j["guest_access"] = info.guest_access;
|
||||
|
||||
if (info.member_count != 0)
|
||||
j["member_count"] = info.member_count;
|
||||
|
||||
if (info.tags.size() != 0)
|
||||
j["tags"] = info.tags;
|
||||
}
|
||||
|
||||
void
|
||||
from_json(const json &j, RoomInfo &info)
|
||||
{
|
||||
info.name = j.at("name");
|
||||
info.topic = j.at("topic");
|
||||
info.avatar_url = j.at("avatar_url");
|
||||
info.version = j.value("version", QCoreApplication::translate("RoomInfo", "no version stored").toStdString());
|
||||
info.is_invite = j.at("is_invite");
|
||||
info.join_rule = j.at("join_rule");
|
||||
info.guest_access = j.at("guest_access");
|
||||
|
||||
if (j.count("member_count"))
|
||||
info.member_count = j.at("member_count");
|
||||
|
||||
if (j.count("tags"))
|
||||
info.tags = j.at("tags").get<std::vector<std::string>>();
|
||||
}
|
||||
|
|
40
src/Cache.h
40
src/Cache.h
|
@ -106,6 +106,8 @@ struct RoomInfo
|
|||
std::string topic;
|
||||
//! The calculated avatar url of the room.
|
||||
std::string avatar_url;
|
||||
//! The calculated version of this room set at creation time.
|
||||
std::string version;
|
||||
//! Whether or not the room is an invite.
|
||||
bool is_invite = false;
|
||||
//! Total number of members in the room.
|
||||
|
@ -119,39 +121,11 @@ struct RoomInfo
|
|||
std::vector<std::string> tags;
|
||||
};
|
||||
|
||||
inline void
|
||||
to_json(json &j, const RoomInfo &info)
|
||||
{
|
||||
j["name"] = info.name;
|
||||
j["topic"] = info.topic;
|
||||
j["avatar_url"] = info.avatar_url;
|
||||
j["is_invite"] = info.is_invite;
|
||||
j["join_rule"] = info.join_rule;
|
||||
j["guest_access"] = info.guest_access;
|
||||
void
|
||||
to_json(json &j, const RoomInfo &info);
|
||||
|
||||
if (info.member_count != 0)
|
||||
j["member_count"] = info.member_count;
|
||||
|
||||
if (info.tags.size() != 0)
|
||||
j["tags"] = info.tags;
|
||||
}
|
||||
|
||||
inline void
|
||||
from_json(const json &j, RoomInfo &info)
|
||||
{
|
||||
info.name = j.at("name");
|
||||
info.topic = j.at("topic");
|
||||
info.avatar_url = j.at("avatar_url");
|
||||
info.is_invite = j.at("is_invite");
|
||||
info.join_rule = j.at("join_rule");
|
||||
info.guest_access = j.at("guest_access");
|
||||
|
||||
if (j.count("member_count"))
|
||||
info.member_count = j.at("member_count");
|
||||
|
||||
if (j.count("tags"))
|
||||
info.tags = j.at("tags").get<std::vector<std::string>>();
|
||||
}
|
||||
void
|
||||
from_json(const json &j, RoomInfo &info);
|
||||
|
||||
//! Basic information per member;
|
||||
struct MemberInfo
|
||||
|
@ -322,6 +296,8 @@ public:
|
|||
lmdb::dbi &statesdb,
|
||||
lmdb::dbi &membersdb,
|
||||
const QString &room_id);
|
||||
//! Retrieve the version of the room if any.
|
||||
QString getRoomVersion(lmdb::txn &txn, lmdb::dbi &statesdb);
|
||||
|
||||
//! Retrieve member info from a room.
|
||||
std::vector<RoomMember> getMembers(const std::string &room_id,
|
||||
|
|
|
@ -199,6 +199,16 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
Qt::AlignBottom | Qt::AlignLeft);
|
||||
roomIdLayout->addWidget(roomIdLabel, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
auto roomVersionLabel = new QLabel(QString::fromStdString(info_.version), this);
|
||||
roomVersionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
roomVersionLabel->setFont(monospaceFont);
|
||||
|
||||
auto roomVersionLayout = new QHBoxLayout;
|
||||
roomVersionLayout->setMargin(0);
|
||||
roomVersionLayout->addWidget(new QLabel(tr("Room Version"), this),
|
||||
Qt::AlignBottom | Qt::AlignLeft);
|
||||
roomVersionLayout->addWidget(roomVersionLabel, 0, Qt::AlignBottom | Qt::AlignRight);
|
||||
|
||||
auto notifLabel = new QLabel(tr("Notifications"), this);
|
||||
auto notifCombo = new QComboBox(this);
|
||||
notifCombo->setDisabled(true);
|
||||
|
@ -400,6 +410,7 @@ RoomSettings::RoomSettings(const QString &room_id, QWidget *parent)
|
|||
layout->addLayout(keyRequestsLayout);
|
||||
layout->addWidget(infoLabel, Qt::AlignLeft);
|
||||
layout->addLayout(roomIdLayout);
|
||||
layout->addLayout(roomVersionLayout);
|
||||
layout->addWidget(errorLabel_);
|
||||
layout->addLayout(buttonLayout);
|
||||
layout->addLayout(spinnerLayout);
|
||||
|
|
Loading…
Reference in a new issue