From e4573ef05905f6ba6e9e8ecc26c3c5852a12c886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederico=20Lu=C3=ADs?= <58048795+Sk4r7z@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:57:54 +0100 Subject: [PATCH] Fix global chat moderation buttons visibility (#393) --- Templates/GlobalChat/widget.tpl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Templates/GlobalChat/widget.tpl b/Templates/GlobalChat/widget.tpl index d7d67f27..0eebc1fd 100644 --- a/Templates/GlobalChat/widget.tpl +++ b/Templates/GlobalChat/widget.tpl @@ -235,6 +235,7 @@ var unread = 0; var isOpen = false; var viewerIsMod = false; + var viewerAccess = 0; var pollTimer = null; function fmtTime(unixTs) { @@ -251,7 +252,10 @@ function escapeForLog(s) { return s; } // (folosim textContent peste tot mai jos - nu innerHTML pe input de utilizator) function renderModActions(row) { - if (!viewerIsMod || row.id_user === myUid || (row.access || 0) >= ACCESS_MH) { + var targetAccess = parseInt(row.access, 10) || 0; + var targetUid = parseInt(row.id_user, 10) || 0; + + if (!viewerIsMod || targetUid === myUid || targetAccess >= viewerAccess) { return null; } @@ -346,7 +350,8 @@ } function applyViewerState(viewer) { - viewerIsMod = !!viewer.isMod; + viewerAccess = parseInt(viewer.access, 10) || 0; + viewerIsMod = viewerAccess >= ACCESS_MH; if (viewer.mutedUntil) { input.disabled = true; @@ -365,8 +370,8 @@ .then(function (r) { return r.json(); }) .then(function (data) { if (!data || !data.ok) { return; } - appendMessages(data.messages || []); applyViewerState(data.viewer || {}); + appendMessages(data.messages || []); }) .catch(function () { /* hiccup de retea - reincercam la urmatorul tick */ }); } @@ -383,8 +388,8 @@ empty.textContent = GCHAT_TXT.empty; messagesBox.appendChild(empty); } - appendMessages(data.messages || []); applyViewerState(data.viewer || {}); + appendMessages(data.messages || []); }); } @@ -442,7 +447,10 @@ showNotice(''); poll(); } else if (data && data.reason === 'muted') { - applyViewerState({ isMod: viewerIsMod, mutedUntil: data.mutedUntil }); + applyViewerState({ + access: viewerAccess, + mutedUntil: data.mutedUntil + }); } else if (data && data.reason === 'ratelimit') { showNotice(GCHAT_TXT.ratelimit); }