luci-app-attendedsysupgrade: fix empty array condition
authorPaul Spooren <mail@aparcar.org>
Sun, 25 Jul 2021 22:36:19 +0000 (00:36 +0200)
committerPaul Spooren <mail@aparcar.org>
Thu, 26 Aug 2021 07:52:00 +0000 (21:52 -1000)
In JavaScript (other than in Python) an empty array is considered `true`
within if statements. Fix this by checking for the array length rather
than its existence.

This fixes the issue of an empty dropdown menu in case the user is
running the latest release.

Signed-off-by: Paul Spooren <mail@aparcar.org>
applications/luci-app-attendedsysupgrade/htdocs/luci-static/resources/view/attendedsysupgrade/overview.js

index f6d31a35beb7c1146b96f35d08f14d586d036d34..3ee99684da11f3ee34632c7619c81e6092ed2a3e 100644 (file)
@@ -255,7 +255,7 @@ function check_sysupgrade(server_url, current_version, target, board_name, packa
                                        }
                                }
                        }
-                       if (candidates) {
+                       if (candidates.length) {
                                var m, s, o;
 
                                var mapdata = {