mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58: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 <QStandardPaths>
|
||||
|
||||
#include <variant.hpp>
|
||||
|
||||
#include "Cache.h"
|
||||
#include "RoomState.h"
|
||||
|
||||
|
@ -420,12 +422,6 @@ Cache::setInvites(const std::map<std::string, mtx::responses::InvitedRoom> &invi
|
|||
if (!isMounted_)
|
||||
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 {
|
||||
auto txn = lmdb::txn::begin(env_);
|
||||
|
||||
|
@ -433,20 +429,9 @@ Cache::setInvites(const std::map<std::string, mtx::responses::InvitedRoom> &invi
|
|||
nlohmann::json j;
|
||||
|
||||
for (const auto &e : it->second.invite_state) {
|
||||
if (mpark::holds_alternative<Name>(e)) {
|
||||
j["invite_state"]["events"].push_back(mpark::get<Name>(e));
|
||||
} else if (mpark::holds_alternative<Topic>(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));
|
||||
}
|
||||
mpark::visit(
|
||||
[&j](auto msg) { j["invite_state"]["events"].push_back(msg); },
|
||||
e);
|
||||
}
|
||||
|
||||
lmdb::dbi_put(txn, invitesDb_, lmdb::val(it->first), lmdb::val(j.dump()));
|
||||
|
|
Loading…
Reference in a new issue