mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Simplify variant usage
This commit is contained in:
parent
f6f46119a6
commit
f9fd03b958
1 changed files with 5 additions and 20 deletions
25
src/Cache.cc
25
src/Cache.cc
|
@ -22,6 +22,8 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#include <variant.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
#include "RoomState.h"
|
#include "RoomState.h"
|
||||||
|
|
||||||
|
@ -420,12 +422,6 @@ Cache::setInvites(const std::map<std::string, mtx::responses::InvitedRoom> &invi
|
||||||
if (!isMounted_)
|
if (!isMounted_)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
using Aliases = mtx::events::StrippedEvent<mtx::events::state::Aliases>;
|
|
||||||
using Avatar = mtx::events::StrippedEvent<mtx::events::state::Avatar>;
|
|
||||||
using Member = mtx::events::StrippedEvent<mtx::events::state::Member>;
|
|
||||||
using Name = mtx::events::StrippedEvent<mtx::events::state::Name>;
|
|
||||||
using Topic = mtx::events::StrippedEvent<mtx::events::state::Topic>;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto txn = lmdb::txn::begin(env_);
|
auto txn = lmdb::txn::begin(env_);
|
||||||
|
|
||||||
|
@ -433,20 +429,9 @@ Cache::setInvites(const std::map<std::string, mtx::responses::InvitedRoom> &invi
|
||||||
nlohmann::json j;
|
nlohmann::json j;
|
||||||
|
|
||||||
for (const auto &e : it->second.invite_state) {
|
for (const auto &e : it->second.invite_state) {
|
||||||
if (mpark::holds_alternative<Name>(e)) {
|
mpark::visit(
|
||||||
j["invite_state"]["events"].push_back(mpark::get<Name>(e));
|
[&j](auto msg) { j["invite_state"]["events"].push_back(msg); },
|
||||||
} else if (mpark::holds_alternative<Topic>(e)) {
|
e);
|
||||||
j["invite_state"]["events"].push_back(mpark::get<Topic>(e));
|
|
||||||
} else if (mpark::holds_alternative<Avatar>(e)) {
|
|
||||||
j["invite_state"]["events"].push_back(
|
|
||||||
mpark::get<Avatar>(e));
|
|
||||||
} else if (mpark::holds_alternative<Aliases>(e)) {
|
|
||||||
j["invite_state"]["events"].push_back(
|
|
||||||
mpark::get<Aliases>(e));
|
|
||||||
} else if (mpark::holds_alternative<Member>(e)) {
|
|
||||||
j["invite_state"]["events"].push_back(
|
|
||||||
mpark::get<Member>(e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lmdb::dbi_put(txn, invitesDb_, lmdb::val(it->first), lmdb::val(j.dump()));
|
lmdb::dbi_put(txn, invitesDb_, lmdb::val(it->first), lmdb::val(j.dump()));
|
||||||
|
|
Loading…
Reference in a new issue