From 15f73258fd9f7e7bc6ee398a0e70df877be62b1e Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 5 Jan 2024 00:40:11 +0100 Subject: [PATCH] Don't run CDB update_detector more than once (#14214) --- builtin/mainmenu/content/update_detector.lua | 10 +++++++++- doc/menu_lua_api.md | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/builtin/mainmenu/content/update_detector.lua b/builtin/mainmenu/content/update_detector.lua index d184272e4..558a0fabb 100644 --- a/builtin/mainmenu/content/update_detector.lua +++ b/builtin/mainmenu/content/update_detector.lua @@ -28,6 +28,13 @@ end local has_fetched = false local latest_releases +do + local tmp = core.get_once("cdb_latest_releases") + if tmp then + latest_releases = core.deserialize(tmp, true) + has_fetched = latest_releases ~= nil + end +end local function fetch_latest_releases() @@ -89,8 +96,9 @@ local function fetch() has_fetched = false return end - latest_releases = lowercase_keys(releases) + core.set_once("cdb_latest_releases", core.serialize(latest_releases)) + if update_detector.get_count() > 0 then local maintab = ui.find_by_name("maintab") if not maintab.hidden then diff --git a/doc/menu_lua_api.md b/doc/menu_lua_api.md index 6c3777f5f..67f7edc69 100644 --- a/doc/menu_lua_api.md +++ b/doc/menu_lua_api.md @@ -38,7 +38,9 @@ Functions --------- * `core.start()` + * start game session * `core.close()` + * exit engine * `core.get_min_supp_proto()` * returns the minimum supported network protocol version * `core.get_max_supp_proto()` @@ -53,6 +55,10 @@ Functions * Android only. Shares file using the share popup * `core.get_version()` (possible in async calls) * returns current core version +* `core.set_once(key, value)`: + * save a string value that persists even if menu is closed +* `core.get_once(key)`: + * get a string value saved by above function, or `nil`