From 4337fc63934b3130e529ff170f3e445cccdeff93 Mon Sep 17 00:00:00 2001 From: Tim Wilkinson Date: Thu, 28 Mar 2024 15:43:09 -0700 Subject: [PATCH] Fix display of previous neighbors (#1133) --- files/www/cgi-bin/mesh | 48 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/files/www/cgi-bin/mesh b/files/www/cgi-bin/mesh index d0252d93..39a9a8cb 100755 --- a/files/www/cgi-bin/mesh +++ b/files/www/cgi-bin/mesh @@ -899,10 +899,12 @@ do end end +local cn = {} if #rows > 0 then table.sort(rows, function(a,b) return a.key < b.key end) for _, row in ipairs(rows) do + cn[row.key] = true html.print(row.row) end -- discard @@ -924,31 +926,32 @@ do else host = host:gsub("^mid%d+%.", ""):gsub("^dtdlink%.", "") end - local row = "" .. host - if hosts[ip] and hosts[ip].hosts then - for _, v in ipairs(hosts[ip].hosts) - do - row = row .. "
" .. v - end - end - row = row .. "" - if age < 3600 then - local val = math.floor(age / 60) - if val == 1 then - row = row .. "1 minute ago" + if not cn[host:lower()] then + local row = "" .. host .. "" + if age < 3600 then + local val = math.floor(age / 60) + if val == 1 then + row = row .. "1 minute ago" + else + row = row .. val .. " minutes ago" + end else - row = row .. val .. " minutes ago" - end - else - local val = string.format("%.1f", age / 3600) - if val == "1.0" then - row = row .. "1 hour ago" - else - row = row .. val .. " hours ago" + local val = string.format("%.1f", age / 3600) + if val == "1.0" then + row = row .. "1 hour ago" + else + row = row .. val .. " hours ago" + end end + if hosts[ip] and hosts[ip].hosts then + for _, v in ipairs(hosts[ip].hosts) + do + row = row .. "" .. v .. "" + end + end + row = row .. "" + rows[#rows + 1] = { key = age, row = row } end - row = row .. "" - rows[#rows + 1] = { key = age, row = row } end end if #rows > 0 then @@ -961,6 +964,7 @@ if #rows > 0 then -- discard rows = nil end +cn = nil -- end current neighbors table html.print("")