Fix mainmenu crash if no servers match search

fixes a regression caused by 6c324cb
This commit is contained in:
Lars Müller 2024-12-06 22:01:31 +01:00 committed by GitHub
parent b857798848
commit ae96a8d4fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -57,6 +57,11 @@ end
-- Persists the selected server in the "address" and "remote_port" settings -- Persists the selected server in the "address" and "remote_port" settings
local function set_selected_server(server) local function set_selected_server(server)
if server == nil then -- reset selection
core.settings:remove("address")
core.settings:remove("remote_port")
return
end
local address = server.address local address = server.address
local port = server.port local port = server.port
gamedata.serverdescription = server.description gamedata.serverdescription = server.description
@ -360,6 +365,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
tabdata.search_for = fields.te_search tabdata.search_for = fields.te_search
search_server_list(fields.te_search:lower()) search_server_list(fields.te_search:lower())
if menudata.search_result then if menudata.search_result then
-- Note: This clears the selection if there are no results
set_selected_server(menudata.search_result[1]) set_selected_server(menudata.search_result[1])
end end