chore(App): add PATCH request to sync user settings with backend before render

This commit is contained in:
shay
2026-04-18 12:40:16 -04:00
parent dd45d49c22
commit eadd074402
2 changed files with 23 additions and 1 deletions
+22
View File
@@ -134,6 +134,28 @@ export default function App() {
setGeneratedSvg(null) setGeneratedSvg(null)
setGenerateError(null) setGenerateError(null)
try { 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' }) const r = await fetch(`/api/${encodeURIComponent(username)}/generate`, { method: 'POST' })
if (r.status === 404) { if (r.status === 404) {
const body = await r.json().catch(() => ({} as { status?: string })) const body = await r.json().catch(() => ({} as { status?: string }))
+1 -1
View File
@@ -96,5 +96,5 @@ def compose_widget(
{embedded} {embedded}
<text x="{total_w // 2}" y="{total_h - 8}" text-anchor="middle" <text x="{total_w // 2}" y="{total_h - 8}" text-anchor="middle"
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif" font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with ♥</text> font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats</text>
</svg>''' </svg>'''