Use the much quicker /api/info/messages/count to get the number of available messages

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2023-05-04 11:37:44 +02:00
parent 99aafc537e
commit 045bfdabd4

View File

@@ -368,20 +368,20 @@ function checkMessages() {
? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") === "true" ? localStorage.getItem("hideNonfatalDnsmasqWarnings_chkbox") === "true"
: false; : false;
$.ajax({ $.ajax({
url: "/api/info/messages" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""), url: "/api/info/messages/count" + (ignoreNonfatal ? "?filter_dnsmasq_warnings=true" : ""),
method: "GET", method: "GET",
dataType: "json", dataType: "json",
}) })
.done(function (data) { .done(function (data) {
if (data.messages.length > 0) { if (data.count > 0) {
var more = '\nAccess "Tools/Pi-hole diganosis" for further details.'; var more = '\nAccess "Tools/Pi-hole diganosis" for further details.';
var title = var title =
data.messages.length > 1 data.count > 1
? "There are " + data.messages.length + " warnings." + more ? "There are " + data.count + " warnings." + more
: "There is one warning." + more; : "There is one warning." + more;
$(".warning-count").prop("title", title); $(".warning-count").prop("title", title);
$(".warning-count").text(data.messages.length); $(".warning-count").text(data.count);
$(".warning-count").removeClass("hidden"); $(".warning-count").removeClass("hidden");
} else { } else {
$(".warning-count").addClass("hidden"); $(".warning-count").addClass("hidden");