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