Skip to content

Commit

Permalink
Don't run CDB update_detector more than once (#14214)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Jan 4, 2024
1 parent 34ce86a commit 15f7325
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion builtin/mainmenu/content/update_detector.lua
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions doc/menu_lua_api.md
Expand Up @@ -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()`
Expand All @@ -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`



Expand Down

0 comments on commit 15f7325

Please sign in to comment.