mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
chore(App): add PATCH request to sync user settings with backend before render
This commit is contained in:
@@ -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 }))
|
||||
|
||||
Reference in New Issue
Block a user