diff --git a/include/plugin.hpp b/include/plugin.hpp index 29b9aa45..cbe04424 100644 --- a/include/plugin.hpp +++ b/include/plugin.hpp @@ -47,7 +47,8 @@ extern std::vector plugins; extern std::string loginStatus; extern std::vector updates; -extern bool updatesFinished; +extern std::string updateStatus; +extern bool restartRequested; } // namespace plugin diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 009209f8..beda3518 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -497,7 +497,20 @@ struct LogInItem : ui::MenuItem { struct SyncItem : ui::MenuItem { void step() override { - disabled = !plugin::hasUpdates() || plugin::isSyncing(); + disabled = true; + if (plugin::updateStatus != "") { + text = plugin::updateStatus; + } + else if (plugin::isSyncing()) { + text = "Updating..."; + } + else if (!plugin::hasUpdates()) { + text = "No updates"; + } + else { + text = "Update all"; + disabled = false; + } MenuItem::step(); } @@ -661,8 +674,8 @@ struct LibraryButton : MenuButton { notification->visible = plugin::hasUpdates(); // Popup when updates finish downloading - if (plugin::updatesFinished) { - plugin::updatesFinished = false; + if (plugin::restartRequested) { + plugin::restartRequested = false; if (osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "All plugins have been downloaded. Close and re-launch Rack to load new updates.")) { APP->window->close(); } diff --git a/src/plugin.cpp b/src/plugin.cpp index 293737e2..a1c679ab 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -351,7 +351,9 @@ bool isLoggedIn() { void queryUpdates() { if (settings::token.empty()) return; + updates.clear(); + updateStatus = "Querying for updates..."; // Get user's plugins list std::string pluginsUrl = app::API_URL + "/plugins"; @@ -361,6 +363,7 @@ void queryUpdates() { json_decref(pluginsReqJ); if (!pluginsResJ) { WARN("Request for user's plugins failed"); + updateStatus = "Could not query updates"; return; } DEFER({ @@ -370,6 +373,7 @@ void queryUpdates() { json_t *errorJ = json_object_get(pluginsResJ, "error"); if (errorJ) { WARN("Request for user's plugins returned an error: %s", json_string_value(errorJ)); + updateStatus = "Could not query updates"; return; } @@ -381,6 +385,7 @@ void queryUpdates() { json_decref(manifestsReq); if (!manifestsResJ) { WARN("Request for library manifests failed"); + updateStatus = "Could not query updates"; return; } DEFER({ @@ -436,6 +441,8 @@ void queryUpdates() { updates.push_back(update); } + + updateStatus = ""; } bool hasUpdates() { @@ -492,7 +499,7 @@ void syncUpdates() { if (update.progress < 1.f) syncUpdate(&update); } - updatesFinished = true; + restartRequested = true; } bool isSyncing() { @@ -641,7 +648,8 @@ std::vector plugins; std::string loginStatus; std::vector updates; -bool updatesFinished = false; +std::string updateStatus; +bool restartRequested = false; } // namespace plugin