mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-25 11:26:47 +08:00
Fix global chat moderation buttons visibility (#393)
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user