Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
- Display PushMessage if Update found
  • Loading branch information
tobid7 committed May 25, 2024
1 parent 859278d commit d1fb538
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
10 changes: 3 additions & 7 deletions source/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Update update_info;
bool checking_for_update = false;
std::string thiz_path;
bool hb_mode;
bool c_is_auto = false;
std::string Clock() {
const time_t ut = time(0);
bool h24 = config.GetBool("24h");
Expand All @@ -32,12 +31,9 @@ std::string Clock() {
}
return std::format("{}:{:02}:{:02}", ts->tm_hour, ts->tm_min, ts->tm_sec);
}
void CheckForUpdate(bool is_auto) {
void CheckForUpdate() {
// Dont create infinite tasks
if (checking_for_update) return;
if (!c_is_auto && is_auto) {
c_is_auto = is_auto;
}
RenderD7::Tasks::Create([&]() {
checking_for_update = true;
update_info = Update();
Expand All @@ -60,7 +56,7 @@ void CheckForUpdate(bool is_auto) {
js[0]["sha"].get_ref<const std::string&>().substr(0, 7);
update_info.text = js[0]["commit"]["message"];
update_info.valid = true;
if (update_info.version.compare(N_STRING) != 0 && c_is_auto) {
if (update_info.version.compare(N_STRING) != 0) {
RenderD7::PushMessage(RD7::Lang::Get("UPDATER"),
RD7::Lang::Get("UPTFND"));
}
Expand All @@ -73,7 +69,7 @@ void CheckForUpdate(bool is_auto) {
}
update_info.text = js["body"];
update_info.valid = true;
if (update_info.version.compare(V_STRING) > 0 && c_is_auto) {
if (update_info.version.substr(1).compare(V_STRING) > 0) {
RenderD7::PushMessage(RD7::Lang::Get("UPDATER"),
RD7::Lang::Get("UPTFND"));
}
Expand Down
2 changes: 1 addition & 1 deletion source/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ extern Config config;
extern std::string thiz_path;
extern bool hb_mode;
std::string Clock();
void CheckForUpdate(bool is_auto = false);
void CheckForUpdate();
} // namespace BP
2 changes: 1 addition & 1 deletion source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) {
aptSetSleepAllowed(false);

RD7::Tasks::Create(Bcstm_Loop);
if (BP::config.GetBool("search_updates")) BP::CheckForUpdate(true);
if (BP::config.GetBool("search_updates")) BP::CheckForUpdate();
BP::player.Stop(); // for ui
RD7::Scene::Load(std::make_unique<BP::MainMenu>());

Expand Down
2 changes: 1 addition & 1 deletion source/scenes/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void Settings::Draw(void) const {
UI7::Checkbox(RD7::Lang::Get("AUTOSEARCHUPDATE"), search_updates);
UI7::Checkbox(RD7::Lang::Get("USENIGHTLY"), use_nightly);
if (UI7::Button(RD7::Lang::Get("CHECK"))) {
BP::CheckForUpdate(true);
BP::CheckForUpdate();
}
if (update_info.valid) {
if (!update_info.nightly &&
Expand Down

0 comments on commit d1fb538

Please sign in to comment.