Style hide bots as toggle

This commit is contained in:
rajchales-monito
2026-07-30 13:29:40 +02:00
parent e80d1f5f9f
commit d59a15d111
3 changed files with 44 additions and 10 deletions
+3 -4
View File
@@ -322,8 +322,8 @@ $("#conversationFilter").addEventListener("change", () => {
renderConversations();
});
$("#hideBotsToggle").addEventListener("click", () => {
state.hideBots = !state.hideBots;
$("#hideBotsToggle").addEventListener("change", (event) => {
state.hideBots = event.target.checked;
localStorage.setItem("mf_admin_hide_bots", state.hideBots ? "1" : "0");
renderVisitors();
});
@@ -1068,8 +1068,7 @@ function conversationVisitorName(item) {
function renderVisitors() {
const visitors = state.hideBots ? state.visitors.filter((visitor) => !visitor.isBot) : state.visitors;
const botCount = state.visitors.filter((visitor) => visitor.isBot).length;
$("#hideBotsToggle").classList.toggle("active", state.hideBots);
$("#hideBotsToggle").textContent = state.hideBots ? "Skryt boty" : "Boty videt";
$("#hideBotsToggle").checked = state.hideBots;
$("#visitorCount").textContent = `${visitors.length} na webu${state.hideBots && botCount ? ` · ${botCount} bot` : ""}`;
$("#visitorList").innerHTML = visitors.length ? visitors.map((visitor) => `
<article class="visitor-card ${visitor.lastConversationId ? "clickable" : ""} ${visitor.lastConversationId === state.activeId ? "active" : ""} ${visitor.isBot ? "bot" : ""}" data-visitor-conversation="${escapeHtml(visitor.lastConversationId || "")}">