Skip to content

Commit

Permalink
fix: disable update notify when user canceled
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflylee committed Aug 30, 2024
1 parent 8bfc33d commit a878f04
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/include/utils/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class AppConfig : public brls::Singleton<AppConfig> {
OVERCLOCK,
APP_THEME,
APP_LANG,
APP_UPDATE,
KEYMAP,
TRANSCODEC,
FORCE_DIRECTPLAY,
Expand Down
14 changes: 8 additions & 6 deletions app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ int main(int argc, char* argv[]) {
}

// Load cookies and settings
if (!AppConfig::instance().init()) {
auto& conf = AppConfig::instance();
if (!conf.init()) {
return 0;
}

Expand Down Expand Up @@ -107,7 +108,7 @@ int main(int argc, char* argv[]) {

if (!brls::Application::getPlatform()->isApplicationMode()) {
brls::Application::pushActivity(new HintActivity());
} else if (!AppConfig::instance().checkLogin()) {
} else if (!conf.checkLogin()) {
brls::Application::pushActivity(new ServerList());
} else if (itemId.empty()) {
brls::Application::pushActivity(new MainActivity());
Expand All @@ -116,14 +117,15 @@ int main(int argc, char* argv[]) {
//brls::sync([view]() { brls::Application::giveFocus(view); });
}

AppVersion::checkUpdate();
std::string v = conf.getItem(AppConfig::APP_UPDATE, std::string("NaN"));
if (AppVersion::getVersion().compare(v)) AppVersion::checkUpdate();

// Run the app
while (brls::Application::mainLoop())
;
while (brls::Application::mainLoop());

ThreadPool::instance().stop();

AppConfig::instance().checkRestart(argv);
conf.checkRestart(argv);
// Exit
return EXIT_SUCCESS;
}
1 change: 1 addition & 0 deletions app/src/utils/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ std::unordered_map<AppConfig::Item, AppConfig::Option> AppConfig::settingMap = {
{APP_THEME, {"app_theme", {"auto", "light", "dark"}}},
{APP_LANG, {"app_lang", {brls::LOCALE_AUTO, brls::LOCALE_EN_US, brls::LOCALE_ZH_HANS, brls::LOCALE_ZH_HANT,
brls::LOCALE_DE, "cs", "uk-UA"}}},
{APP_UPDATE, {"app_update"}},
{KEYMAP, {"keymap", {"xbox", "ps", "keyboard"}}},
{TRANSCODEC, {"transcodec", {"h264", "hevc", "av1"}}},
{FORCE_DIRECTPLAY, {"force_directplay"}},
Expand Down
10 changes: 8 additions & 2 deletions app/src/utils/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ void AppVersion::checkUpdate(int delay, bool showUpToDateDialog) {

brls::sync([latest_ver]() {
std::string title = brls::getStr("main/setting/others/upgrade", latest_ver);
auto dialog = new brls::Dialog(title);
dialog->addButton("hints/cancel"_i18n, []() {
auto& conf = AppConfig::instance();
conf.setItem(AppConfig::APP_UPDATE, getVersion());
});
#ifdef __SWITCH__
Dialog::cancelable(title, [latest_ver]() {
dialog->addButton("hints/ok"_i18n, [latest_ver]() {
AppVersion::updating->store(false);
ThreadPool::instance().submit([latest_ver]() {
std::string conf_dir = AppConfig::instance().configDir();
Expand All @@ -121,8 +126,9 @@ void AppVersion::checkUpdate(int delay, bool showUpToDateDialog) {
});
#else
std::string url = fmt::format("https://github.com/{}/releases/tag/{}", git_repo, latest_ver);
Dialog::cancelable(title, [url] { brls::Application::getPlatform()->openBrowser(url); });
dialog->addButton("hints/ok"_i18n, [url] { brls::Application::getPlatform()->openBrowser(url); });
#endif
dialog->open();
});
} catch (const std::exception& ex) {
brls::Logger::error("checkUpdate failed: {}", ex.what());
Expand Down

0 comments on commit a878f04

Please sign in to comment.