Load grid branding before connect

This commit is contained in:
Jage9
2026-03-09 01:39:30 -04:00
parent 6aaa49bed3
commit b49412a800
4 changed files with 50 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
// Maintainer-controlled web client version metadata.
window.CHGRID_RELEASE_VERSION = "0.1.0";
window.CHGRID_BUILD_REVISION = "R347";
window.CHGRID_BUILD_REVISION = "R348";
window.CHGRID_WEB_VERSION = `${window.CHGRID_RELEASE_VERSION} ${window.CHGRID_BUILD_REVISION}`;
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -366,6 +366,7 @@ loadMasterVolume();
void loadHelp();
void itemBehaviorRegistry.initialize();
void loadChangelog();
void loadClientBranding();
function applyGridBranding(gridName: string | null | undefined, welcomeMessage: string | null | undefined): void {
const nextGridName = String(gridName ?? '').trim() || DEFAULT_GRID_NAME;
@@ -378,6 +379,25 @@ function applyGridBranding(gridName: string | null | undefined, welcomeMessage:
dom.canvas.setAttribute('aria-label', `${nextGridName}, press question mark for help.`);
}
async function loadClientBranding(): Promise<void> {
try {
const response = await fetch(withBase('client_branding.json'), { cache: 'no-store' });
if (!response.ok) {
return;
}
const data = (await response.json()) as { gridName?: unknown; welcomeMessage?: unknown };
applyGridBranding(
typeof data.gridName === 'string' ? data.gridName : null,
typeof data.welcomeMessage === 'string' ? data.welcomeMessage : null,
);
if (!state.running && !isVersionReloadedSession()) {
setConnectionStatus(activeWelcomeMessage);
}
} catch {
// Branding falls back to built-in defaults when deploy-time branding is unavailable.
}
}
/** Fetches a required DOM element and casts it to the requested element type. */
function requiredById<T extends HTMLElement>(id: string): T {
const found = document.getElementById(id);