Fix mainmenu code downloading the public serverlist twice.
authorEkdohibs <nathanael.courant@laposte.net>
Fri, 22 Apr 2016 12:20:16 +0000 (14:20 +0200)
committerCraig Robbins <kde.psych@gmail.com>
Fri, 22 Apr 2016 13:39:54 +0000 (23:39 +1000)
Also, fix a nil error that can happen sometimes in
menu_handle_key_up_down

builtin/mainmenu/common.lua

index 5bf39abd75338e51506c61e39cf55999f535c871..1fd89ff7793533abb3225c08edc265d75d6c7bb3 100644 (file)
@@ -178,7 +178,7 @@ end
 
 --------------------------------------------------------------------------------
 function menu_handle_key_up_down(fields, textlist, settingname)
-       local oldidx, newidx = core.get_textlist_index(textlist)
+       local oldidx, newidx = core.get_textlist_index(textlist), 1
        if fields.key_up or fields.key_down then
                if fields.key_up and oldidx and oldidx > 1 then
                        newidx = oldidx - 1
@@ -203,12 +203,20 @@ function asyncOnlineFavourites()
        end
        menudata.favorites = menudata.public_known
        menudata.favorites_is_public = true
+
+       if not menudata.public_downloading then
+               menudata.public_downloading = true
+       else
+               return
+       end
+
        core.handle_async(
                function(param)
                        return core.get_favorites("online")
                end,
                nil,
                function(result)
+                       menudata.public_downloading = nil
                        local favs = order_favorite_list(result)
                        if favs[1] then
                                menudata.public_known = favs