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)
|
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 }))
|
||||||
|
|||||||
@@ -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>'''
|
||||||
|
|||||||
Reference in New Issue
Block a user