Remove client fallback for readonly item property display
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Maintainer-controlled web client version.
|
||||
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
|
||||
window.CHGRID_WEB_VERSION = "2026.02.25 R276";
|
||||
window.CHGRID_WEB_VERSION = "2026.02.25 R277";
|
||||
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
|
||||
window.CHGRID_TIME_ZONE = "America/Detroit";
|
||||
|
||||
@@ -7,12 +7,8 @@ import {
|
||||
itemPropertyLabel,
|
||||
} from './itemRegistry';
|
||||
|
||||
type PresentationDeps = {
|
||||
formatTimestampMs: (value: unknown) => string;
|
||||
};
|
||||
|
||||
/** Builds shared item-property presentation/validation helpers used by item menus and message echoes. */
|
||||
export function createItemPropertyPresentation(deps: PresentationDeps): {
|
||||
export function createItemPropertyPresentation(): {
|
||||
getItemPropertyValue: (item: WorldItem, key: string) => string;
|
||||
isItemPropertyEditable: (item: WorldItem, key: string) => boolean;
|
||||
describeItemPropertyHelp: (item: WorldItem, key: string) => string;
|
||||
@@ -59,17 +55,6 @@ export function createItemPropertyPresentation(deps: PresentationDeps): {
|
||||
if (metadata?.valueType === 'list' || metadata?.valueType === 'text') {
|
||||
return rawValue === undefined || rawValue === null ? '' : String(rawValue);
|
||||
}
|
||||
if (key === 'type') return item.type;
|
||||
if (key === 'x') return String(item.x);
|
||||
if (key === 'y') return String(item.y);
|
||||
if (key === 'carrierId') return item.carrierId ?? 'none';
|
||||
if (key === 'version') return String(item.version);
|
||||
if (key === 'createdBy') return item.createdBy;
|
||||
if (key === 'createdAt') return deps.formatTimestampMs(item.createdAt);
|
||||
if (key === 'updatedAt') return deps.formatTimestampMs(item.updatedAt);
|
||||
if (key === 'capabilities') return item.capabilities.join(', ') || 'none';
|
||||
if (key === 'useSound') return toSoundDisplayName(item.params.useSound ?? item.useSound);
|
||||
if (key === 'emitSound') return toSoundDisplayName(item.params.emitSound ?? item.emitSound);
|
||||
if (paramValue !== undefined) return String(paramValue);
|
||||
if (globalValue !== undefined) return String(globalValue);
|
||||
return '';
|
||||
|
||||
@@ -64,7 +64,6 @@ import { type AudioLayerState } from './types/audio';
|
||||
import { setupUiHandlers as setupDomUiHandlers } from './ui/domBindings';
|
||||
import { PeerManager } from './webrtc/peerManager';
|
||||
|
||||
const DEFAULT_DISPLAY_TIME_ZONE = 'America/Detroit';
|
||||
const NICKNAME_MAX_LENGTH = 32;
|
||||
const MIC_CALIBRATION_DURATION_MS = 5000;
|
||||
const MIC_CALIBRATION_SAMPLE_INTERVAL_MS = 50;
|
||||
@@ -84,7 +83,6 @@ const AUTH_POLICY_STORAGE_KEY = 'chgridAuthPolicy';
|
||||
declare global {
|
||||
interface Window {
|
||||
CHGRID_WEB_VERSION?: string;
|
||||
CHGRID_TIME_ZONE?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +199,6 @@ function buildHelpLines(help: HelpData): string[] {
|
||||
}
|
||||
|
||||
const APP_VERSION = String(window.CHGRID_WEB_VERSION ?? '').trim();
|
||||
const DISPLAY_TIME_ZONE = resolveDisplayTimeZone();
|
||||
dom.appVersion.textContent = APP_VERSION
|
||||
? `Another AI experiment with Jage. Version ${APP_VERSION}`
|
||||
: 'Another AI experiment with Jage. Version unknown';
|
||||
@@ -349,44 +346,7 @@ function requiredById<T extends HTMLElement>(id: string): T {
|
||||
return found as T;
|
||||
}
|
||||
|
||||
/** Returns the configured display timezone when valid, otherwise the default fallback. */
|
||||
function resolveDisplayTimeZone(): string {
|
||||
const configured = String(window.CHGRID_TIME_ZONE ?? '').trim();
|
||||
if (configured) {
|
||||
try {
|
||||
new Intl.DateTimeFormat('en-US', { timeZone: configured }).format(new Date());
|
||||
return configured;
|
||||
} catch {
|
||||
// Fall back when configured timezone is invalid.
|
||||
}
|
||||
}
|
||||
return DEFAULT_DISPLAY_TIME_ZONE;
|
||||
}
|
||||
|
||||
/** Formats epoch milliseconds as `YYYY-MM-DD HH:mm` in the configured display timezone. */
|
||||
function formatTimestampMs(value: unknown): string {
|
||||
const raw = Number(value);
|
||||
if (!Number.isFinite(raw)) {
|
||||
return String(value ?? '');
|
||||
}
|
||||
const date = new Date(raw);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return String(value ?? '');
|
||||
}
|
||||
const parts = new Intl.DateTimeFormat('en-CA', {
|
||||
timeZone: DISPLAY_TIME_ZONE,
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
}).formatToParts(date);
|
||||
const pick = (type: Intl.DateTimeFormatPartTypes): string => parts.find((part) => part.type === type)?.value ?? '00';
|
||||
return `${pick('year')}-${pick('month')}-${pick('day')} ${pick('hour')}:${pick('minute')}`;
|
||||
}
|
||||
|
||||
const itemPropertyPresentation = createItemPropertyPresentation({ formatTimestampMs });
|
||||
const itemPropertyPresentation = createItemPropertyPresentation();
|
||||
const getItemPropertyValue = itemPropertyPresentation.getItemPropertyValue;
|
||||
const isItemPropertyEditable = itemPropertyPresentation.isItemPropertyEditable;
|
||||
const describeItemPropertyHelp = itemPropertyPresentation.describeItemPropertyHelp;
|
||||
|
||||
Reference in New Issue
Block a user