From eadd0744022e235d93222e2790d52ae917feec9f Mon Sep 17 00:00:00 2001 From: shay Date: Sat, 18 Apr 2026 12:40:16 -0400 Subject: [PATCH] chore(App): add PATCH request to sync user settings with backend before render --- generator/frontend/src/App.tsx | 22 ++++++++++++++++++++++ generator/src/widgets/composite.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/generator/frontend/src/App.tsx b/generator/frontend/src/App.tsx index 6958c35..42ea5a9 100644 --- a/generator/frontend/src/App.tsx +++ b/generator/frontend/src/App.tsx @@ -134,6 +134,28 @@ export default function App() { setGeneratedSvg(null) setGenerateError(null) try { + // Push the user's Workshop choices to the backend BEFORE rendering. + // The backend's /generate endpoint re-reads settings from SQLite and + // renders with them, so without this PATCH the SVG would reflect + // whatever was last persisted (usually the enroll-time defaults) + // rather than the user's current selections. + const backendSettings = { + theme: settings.theme, + enabled: settings.widgets, + custom_tags: settings.customTags, + hidden_languages: settings.hiddenLanguages, + widget_settings: settings.widgetSettings, + } + const patchRes = await fetch(`/api/${encodeURIComponent(username)}/settings`, { + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(backendSettings), + }) + if (!patchRes.ok && patchRes.status !== 404) { + setGenerateError(`Settings sync failed (HTTP ${patchRes.status})`) + return + } + const r = await fetch(`/api/${encodeURIComponent(username)}/generate`, { method: 'POST' }) if (r.status === 404) { const body = await r.json().catch(() => ({} as { status?: string })) diff --git a/generator/src/widgets/composite.py b/generator/src/widgets/composite.py index eeea4a8..2a6f7a5 100644 --- a/generator/src/widgets/composite.py +++ b/generator/src/widgets/composite.py @@ -96,5 +96,5 @@ def compose_widget( {embedded} Generated with ♥ + font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats '''