Staff playtime figures on the staff panel only

Signed-in staff now see the public Playtime page and player drawers as
everyone else does; the staff panels, names, sessions and locations stay
on /admin#playtime and its drawers. The public API no longer sends them.
This commit is contained in:
Astra 2026-10-05 12:35:14 +01:00
parent ba61708bed
commit 9aeea45130
5 changed files with 22 additions and 23 deletions

View file

@ -1,6 +1,7 @@
// Playtime from PlaytimeHistory, shared by the public site and the staff panel: the Playtime page
// and the Playtime sections of a player's drawer. Staff with @css/generic (me.playtimeStaff) also
// get the staff-only figures, on either site. Needs common.js.
// and the Playtime sections of a player's drawer. On the staff panel, staff with @css/generic
// (me.playtimeStaff) also get the staff-only figures; the public site shows everyone the same.
// Needs common.js.
const PT_TZ = (() => { try { return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC"; } catch { return "UTC"; } })();
const PT_PERIODS = [["7d", "Last 7 days"], ["30d", "Last 30 days"], ["all", "All time"]];
@ -266,11 +267,12 @@ function ptStaffPanels(a) {
/* ---------- Page ---------- */
// ptPage draws the Playtime page into #view: the staff panels first when this viewer may see them,
// then the public ones. isCurrent says whether the user is still on the page when data arrives.
async function ptPage(me, isCurrent) {
// ptPage draws the Playtime page into #view: with staff (the staff panel, for staff who may see
// them), the staff panels first, then the public ones. isCurrent says whether the user is still on
// the page when data arrives.
async function ptPage(me, isCurrent, staffPanels = false) {
const v = $("#view");
const staff = !!me?.playtimeStaff;
const staff = staffPanels && !!me?.playtimeStaff;
v.innerHTML = `
<div class="page-head"><div><h1>Playtime</h1></div></div>
${staff ? `<div id="pt-staff">${loading()}</div><h2 class="crew-sep">${me.playtime === "on" ? "On the public site" : ""}</h2>` : ""}