Fix global chat moderation buttons visibility (#393)

This commit is contained in:
Frederico Luís
2026-09-08 15:57:54 +01:00
committed by GitHub
parent 009bba0ce6
commit e4573ef059
+13 -5
View File
@@ -235,6 +235,7 @@
var unread = 0; var unread = 0;
var isOpen = false; var isOpen = false;
var viewerIsMod = false; var viewerIsMod = false;
var viewerAccess = 0;
var pollTimer = null; var pollTimer = null;
function fmtTime(unixTs) { 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 escapeForLog(s) { return s; } // (folosim textContent peste tot mai jos - nu innerHTML pe input de utilizator)
function renderModActions(row) { 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; return null;
} }
@@ -346,7 +350,8 @@
} }
function applyViewerState(viewer) { function applyViewerState(viewer) {
viewerIsMod = !!viewer.isMod; viewerAccess = parseInt(viewer.access, 10) || 0;
viewerIsMod = viewerAccess >= ACCESS_MH;
if (viewer.mutedUntil) { if (viewer.mutedUntil) {
input.disabled = true; input.disabled = true;
@@ -365,8 +370,8 @@
.then(function (r) { return r.json(); }) .then(function (r) { return r.json(); })
.then(function (data) { .then(function (data) {
if (!data || !data.ok) { return; } if (!data || !data.ok) { return; }
appendMessages(data.messages || []);
applyViewerState(data.viewer || {}); applyViewerState(data.viewer || {});
appendMessages(data.messages || []);
}) })
.catch(function () { /* hiccup de retea - reincercam la urmatorul tick */ }); .catch(function () { /* hiccup de retea - reincercam la urmatorul tick */ });
} }
@@ -383,8 +388,8 @@
empty.textContent = GCHAT_TXT.empty; empty.textContent = GCHAT_TXT.empty;
messagesBox.appendChild(empty); messagesBox.appendChild(empty);
} }
appendMessages(data.messages || []);
applyViewerState(data.viewer || {}); applyViewerState(data.viewer || {});
appendMessages(data.messages || []);
}); });
} }
@@ -442,7 +447,10 @@
showNotice(''); showNotice('');
poll(); poll();
} else if (data && data.reason === 'muted') { } else if (data && data.reason === 'muted') {
applyViewerState({ isMod: viewerIsMod, mutedUntil: data.mutedUntil }); applyViewerState({
access: viewerAccess,
mutedUntil: data.mutedUntil
});
} else if (data && data.reason === 'ratelimit') { } else if (data && data.reason === 'ratelimit') {
showNotice(GCHAT_TXT.ratelimit); showNotice(GCHAT_TXT.ratelimit);
} }