summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-26 20:41:16 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-03-26 20:41:16 +0300
commitf9fd03b9589c5c299e2c360f464975d3f237f5a2 (patch)
treed3e0a1899b9ddeeaa2aac2dabcf45afbedbf011f /src
parentFix CI errors (diff)
downloadnheko-f9fd03b9589c5c299e2c360f464975d3f237f5a2.tar.xz
Simplify variant usage
Diffstat (limited to '')
-rw-r--r--src/Cache.cc25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/Cache.cc b/src/Cache.cc
index 8a58b634..3c8a1bb3 100644
--- a/src/Cache.cc
+++ b/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()));