Share the font map with the function that renders it

_vvNcStyle referenced a const declared inside vvNcRender, so with the
formatting toggle on every mesh transcript threw ReferenceError and drew
nothing. The plain-render early return skipped the line, which is why it looked
like a slow load rather than a broken one.
This commit is contained in:
Gmer4Lfe
2026-08-21 09:05:21 -04:00
parent e1cdf03d40
commit 906375dc23
+9 -2
View File
@@ -413,6 +413,14 @@ function vvNcToggleFmt() {
// Style string for a message. Closed set on both ends — the server validates the same values, // Style string for a message. Closed set on both ends — the server validates the same values,
// so nothing here can emit a property the store did not agree to. // so nothing here can emit a property the store did not agree to.
// Module scope, because two functions need it: _vvNcStyle() renders with it and vvNcRender() used
// to declare its own copy. The copy was a `const` inside vvNcRender, so the reference here — in a
// different function — resolved to nothing and threw ReferenceError on every render, but only with
// the formatting toggle on, since the plain-render early return below skips the line that uses it.
// Every mesh transcript therefore failed to draw for anyone who had formatting enabled, and the
// empty catch on the fetch swallowed the reason.
const _VV_NC_FONTS = { mono: 'monospace', sans: 'system-ui,sans-serif', serif: 'Georgia,serif' };
function _vvNcStyle(m, mine) { function _vvNcStyle(m, mine) {
// Reader wins over sender. Someone else's purple italic large is their idea of emphasis, and // Reader wins over sender. Someone else's purple italic large is their idea of emphasis, and
// on a wall-mounted dashboard it is noise — this renders every message plain here without // on a wall-mounted dashboard it is noise — this renders every message plain here without
@@ -423,7 +431,7 @@ function _vvNcStyle(m, mine) {
const st = m.style || {}; const st = m.style || {};
const sizes = { sm: '11px', lg: '14px' }; const sizes = { sm: '11px', lg: '14px' };
let s = `color:${st.color || (mine ? '#7a9a7a' : '#9aa')};`; let s = `color:${st.color || (mine ? '#7a9a7a' : '#9aa')};`;
if (fonts[st.font]) s += `font-family:${fonts[st.font]};`; if (_VV_NC_FONTS[st.font]) s += `font-family:${_VV_NC_FONTS[st.font]};`;
s += `font-size:${sizes[st.size] || '12px'};`; s += `font-size:${sizes[st.size] || '12px'};`;
if (st.bold) s += 'font-weight:700;'; if (st.bold) s += 'font-weight:700;';
if (st.italic) s += 'font-style:italic;'; if (st.italic) s += 'font-style:italic;';
@@ -528,7 +536,6 @@ function vvNcRender() {
+ (unreadOnly ? 'Nothing new.' : 'No messages yet — say hello.') + `</div>`; + (unreadOnly ? 'Nothing new.' : 'No messages yet — say hello.') + `</div>`;
return; return;
} }
const fonts = { mono: 'monospace', sans: 'system-ui,sans-serif', serif: 'Georgia,serif' };
box.innerHTML = msgs.map(m => { box.innerHTML = msgs.map(m => {
const mine = m.from === _vvNc.me; const mine = m.from === _vvNc.me;
const fresh = (m.ts || 0) > _vvNc.lastRead && !mine; const fresh = (m.ts || 0) > _vvNc.lastRead && !mine;