From 1be20063595206d42ec95a5028b8ecf8f7567476 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 28 Dec 2020 03:12:15 -0500 Subject: offline mode: - don't try to login on startup - don't try to update loot when sorting and display a warning that the master list might be stale --- src/mainwindow.cpp | 31 +++++++++++++++++++++++++------ src/nxmaccessmanager.cpp | 5 +++++ src/organizercore.cpp | 2 +- 3 files changed, 31 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1e7741ac..ce1dc3d1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -6181,10 +6181,22 @@ void MainWindow::on_showHiddenBox_toggled(bool checked) void MainWindow::on_bossButton_clicked() { - const auto r = QMessageBox::question( - this, tr("Sorting plugins"), - tr("Are you sure you want to sort your plugins list?"), - QMessageBox::Yes | QMessageBox::No); + const bool offline = m_OrganizerCore.settings().network().offlineMode(); + + auto r = QMessageBox::No; + + if (offline) { + r = QMessageBox::question( + this, tr("Sorting plugins"), + tr("Are you sure you want to sort your plugins list?") + "\r\n\r\n" + + tr("Note: You are currently in offline mode and LOOT will not update the master list."), + QMessageBox::Yes | QMessageBox::No); + } else { + r = QMessageBox::question( + this, tr("Sorting plugins"), + tr("Are you sure you want to sort your plugins list?"), + QMessageBox::Yes | QMessageBox::No); + } if (r != QMessageBox::Yes) { return; @@ -6196,8 +6208,15 @@ void MainWindow::on_bossButton_clicked() setEnabled(false); ON_BLOCK_EXIT([&] () { setEnabled(true); }); - if (runLoot(this, m_OrganizerCore, m_DidUpdateMasterList)) { - m_DidUpdateMasterList = true; + // don't try to update the master list in offline mode + const bool didUpdateMasterList = offline ? true : m_DidUpdateMasterList; + + if (runLoot(this, m_OrganizerCore, didUpdateMasterList)) { + // don't assume the master list was updated in offline mode + if (!offline) { + m_DidUpdateMasterList = true; + } + m_OrganizerCore.refreshESPList(false); m_OrganizerCore.savePluginList(); } diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 30108c21..001e1bb1 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -935,6 +935,11 @@ void NXMAccessManager::apiCheck(const QString &apiKey, bool force) return; } + if (m_Settings && m_Settings->network().offlineMode()) { + m_validationState = NotChecked; + return; + } + if (force) { m_validationState = NotChecked; } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 631e49be..569faccb 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1430,7 +1430,7 @@ void OrganizerCore::loggedInAction(QWidget* parent, std::function f) { if (NexusInterface::instance().getAccessManager()->validated()) { f(); - } else { + } else if (!m_Settings.network().offlineMode()) { QString apiKey; if (GlobalSettings::nexusApiKey(apiKey)) { doAfterLogin([f]{ f(); }); -- cgit v1.3.1