diff --git a/src/common/Credentials.cpp b/src/common/Credentials.cpp index 26f9231ce..b36f05c5c 100644 --- a/src/common/Credentials.cpp +++ b/src/common/Credentials.cpp @@ -101,46 +101,47 @@ namespace { if (!queue.empty()) { - std::visit( - Overloaded{ - [](const SetJob &set) { - qDebug() << "set"; - auto job = - new QKeychain::WritePasswordJob("chatterino"); - job->setAutoDelete(true); - job->setKey(set.name); - job->setTextData(set.credential); - QObject::connect(job, &QKeychain::Job::finished, qApp, - [](auto) { runNextJob(); }); - job->start(); - }, - [](const EraseJob &erase) { - qDebug() << "erase"; - auto job = - new QKeychain::DeletePasswordJob("chatterino"); - job->setAutoDelete(true); - job->setKey(erase.name); - QObject::connect(job, &QKeychain::Job::finished, qApp, - [](auto) { runNextJob(); }); - job->start(); - }}, - queue.front()); - queue.pop(); - } - } + // we were gonna use std::visit here but macos is shit - static void queueJob(Job &&job) - { - auto &&queue = jobQueue(); - - queue.push(std::move(job)); - if (queue.size() == 1) - { - runNextJob(); + auto &&item = queue.front(); + if (item.index() == 0) // set job + { + auto set = std::get(item); + auto job = new QKeychain::WritePasswordJob("chatterino"); + job->setAutoDelete(true); + job->setKey(set.name); + job->setTextData(set.credential); + QObject::connect(job, &QKeychain::Job::finished, qApp, + [](auto) { runNextJob(); }); + job->start(); + } + else // erase job + { + auto erase = std::get(item); + auto job = new QKeychain::DeletePasswordJob("chatterino"); + job->setAutoDelete(true); + job->setKey(erase.name); + QObject::connect(job, &QKeychain::Job::finished, qApp, + [](auto) { runNextJob(); }); + job->start(); + } } + queue.pop(); } } // namespace +static void queueJob(Job &&job) +{ + auto &&queue = jobQueue(); + + queue.push(std::move(job)); + if (queue.size() == 1) + { + runNextJob(); + } +} +} // namespace chatterino + Credentials &Credentials::getInstance() { static Credentials creds;