1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-11-08 11:31:43 +00:00

fixed crash in airplane mode

This commit is contained in:
flb 2021-09-15 17:50:34 +02:00
parent 25dffbf611
commit 4a0f8318d7
4 changed files with 14 additions and 8 deletions

View file

@ -46,4 +46,5 @@ namespace util {
bool isApplet();
std::string getContentsPath();
bool getBoolValue(const nlohmann::json& jsonFile, const std::string& key);
const nlohmann::ordered_json getValueFromKey(const nlohmann::ordered_json& jsonFile, const std::string& key);
} // namespace util

View file

@ -18,13 +18,13 @@ using namespace i18n::literals;
AmsTab::AmsTab(const nlohmann::json& nxlinks, const bool erista, const bool hideStandardEntries) : brls::List()
{
this->erista = erista;
this->hekate = nxlinks["hekate"];
auto cfws = nxlinks["cfws"];
this->hekate = util::getValueFromKey(nxlinks, "hekate");
auto cfws = util::getValueFromKey(nxlinks, "cfws");
if (!hideStandardEntries) {
this->description = new brls::Label(brls::LabelStyle::DESCRIPTION, "menus/main/ams_text"_i18n + (CurrentCfw::running_cfw == CFW::ams ? "\n" + "menus/ams_update/current_ams"_i18n + CurrentCfw::getAmsInfo() : "") + (erista ? "\n" + "menus/ams_update/erista_rev"_i18n : "\n" + "menus/ams_update/mariko_rev"_i18n), true);
this->addView(description);
CreateDownloadItems(cfws.find("Atmosphere") != cfws.end() ? (nlohmann::ordered_json) cfws.at("Atmosphere") : nlohmann::ordered_json::object());
CreateDownloadItems(util::getValueFromKey(cfws, "Atmosphere"));
description = new brls::Label(
brls::LabelStyle::DESCRIPTION,
@ -41,7 +41,7 @@ AmsTab::AmsTab(const nlohmann::json& nxlinks, const bool erista, const bool hide
});
this->addView(listItem);
CreateDownloadItems(cfws.find("DeepSea") != cfws.end() ? (nlohmann::ordered_json) cfws.at("DeepSea") : nlohmann::ordered_json::object());
CreateDownloadItems(util::getValueFromKey(cfws, "DeepSea"));
}
auto custom_pack = fs::parseJsonFile(CUSTOM_PACKS_PATH);

View file

@ -44,19 +44,19 @@ MainFrame::MainFrame() : TabFrame()
this->addTab("menus/main/update_ams"_i18n, new AmsTab(nxlinks, erista, util::getBoolValue(hideStatus, "atmosphereentries")));
if (!util::getBoolValue(hideStatus, "cfw"))
this->addTab("menus/main/update_bootloaders"_i18n, new ListDownloadTab(archiveType::bootloaders, nxlinks["bootloaders"]));
this->addTab("menus/main/update_bootloaders"_i18n, new ListDownloadTab(archiveType::bootloaders, util::getValueFromKey(nxlinks, "bootloaders")));
if (!util::getBoolValue(hideStatus, "sigpatches"))
this->addTab("menus/main/update_sigpatches"_i18n, new ListDownloadTab(archiveType::sigpatches, nxlinks["sigpatches"]));
this->addTab("menus/main/update_sigpatches"_i18n, new ListDownloadTab(archiveType::sigpatches, util::getValueFromKey(nxlinks, "sigpatches")));
if (!util::getBoolValue(hideStatus, "firmwares"))
this->addTab("menus/main/download_firmware"_i18n, new ListDownloadTab(archiveType::fw, nxlinks["firmwares"]));
this->addTab("menus/main/download_firmware"_i18n, new ListDownloadTab(archiveType::fw, util::getValueFromKey(nxlinks, "firmwares")));
if (!util::getBoolValue(hideStatus, "cheats"))
this->addTab("menus/main/download_cheats"_i18n, new ListDownloadTab(archiveType::cheats));
if (!util::getBoolValue(hideStatus, "tools"))
this->addTab("menus/main/tools"_i18n, new ToolsTab(tag, nxlinks["payloads"], erista, hideStatus));
this->addTab("menus/main/tools"_i18n, new ToolsTab(tag, util::getValueFromKey(nxlinks, "payloads"), erista, hideStatus));
this->registerAction("", brls::Key::B, [this] { return true; });
}

View file

@ -355,4 +355,9 @@ namespace util {
return (jsonFile.find(key) != jsonFile.end()) ? jsonFile.at(key).get<bool>() : false;
}
const nlohmann::ordered_json getValueFromKey(const nlohmann::ordered_json& jsonFile, const std::string& key)
{
return (jsonFile.find(key) != jsonFile.end()) ? jsonFile.at(key) : nlohmann::ordered_json::object();
}
} // namespace util