diff --git a/include/library.hpp b/include/library.hpp index e7127a9f..a27293c2 100644 --- a/include/library.hpp +++ b/include/library.hpp @@ -13,6 +13,8 @@ struct UpdateInfo { std::string name; std::string version; std::string changelogUrl; + /** Only defined if plugin does not meet Rack version requirement */ + std::string minRackVersion; bool downloaded = false; }; diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index e3c30841..8d1d28ba 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -664,26 +664,37 @@ struct SyncUpdateItem : ui::MenuItem { return NULL; library::UpdateInfo update = it->second; - if (update.changelogUrl == "") - return NULL; - ui::Menu* menu = new ui::Menu; - std::string changelogUrl = update.changelogUrl; - menu->addChild(createMenuItem("Changelog", "", [=]() { - system::openBrowser(changelogUrl); - })); + if (update.minRackVersion != "") { + menu->addChild(createMenuLabel(string::f("Requires Rack %s+", update.minRackVersion.c_str()))); + } + + if (update.changelogUrl != "") { + std::string changelogUrl = update.changelogUrl; + menu->addChild(createMenuItem("Changelog", "", [=]() { + system::openBrowser(changelogUrl); + })); + } + if (menu->children.empty()) { + delete menu; + return NULL; + } return menu; } void step() override { - disabled = library::isSyncing; + if (library::isSyncing) + disabled = true; auto it = library::updateInfos.find(slug); if (it != library::updateInfos.end()) { library::UpdateInfo update = it->second; + if (update.minRackVersion != "") + disabled = true; + if (update.downloaded) { rightText = CHECKMARK_STRING; disabled = true; diff --git a/src/library.cpp b/src/library.cpp index b621d8e7..716f35d5 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace rack { @@ -278,6 +279,16 @@ void checkUpdates() { if (changelogUrlJ) update.changelogUrl = json_string_value(changelogUrlJ); + // Get minRackVersion + json_t* minRackVersionJ = json_object_get(manifestJ, "minRackVersion"); + if (minRackVersionJ) { + std::string minRackVersion = json_string_value(minRackVersionJ); + // Check that Rack version is at least minRackVersion + if (string::Version(APP_VERSION) < string::Version(minRackVersion)) { + update.minRackVersion = minRackVersion; + } + } + // Add update to updates map updateInfos[pluginSlug] = update; } @@ -349,6 +360,10 @@ void syncUpdate(std::string slug) { return; UpdateInfo update = it->second; + // Don't update if not compatible with Rack version + if (update.minRackVersion != "") + return; + updateSlug = slug; DEFER({updateSlug = "";});