fix: Design-PATCH fehlte Bearer-Token + Race Condition bei Fertigstellen
- Neues updateDbPicture() in api.ts mit korrektem Bearer-Header - Design-onChange nutzt updateDbPicture statt rohem fetch (kein Bearer-Bug mehr) - finishPicture sendet status + design in einem PATCH (kein Race Condition) - app.py: get_json(force=True, silent=True) für db-pictures PATCH Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import BlurhashCanvas from '../components/BlurhashCanvas'
|
||||
import Topbar from '../components/Topbar'
|
||||
import {
|
||||
getDbPictures,
|
||||
updateDbPicture,
|
||||
updateDbPictureStatus,
|
||||
getDbObjects,
|
||||
createDbObject,
|
||||
@@ -225,7 +226,11 @@ export default function DrawIt() {
|
||||
if (!currentPicture || !token) return
|
||||
setFinishing(true)
|
||||
try {
|
||||
await updateDbPictureStatus(currentPicture.id, 'objects_created', token)
|
||||
// Save status + current design in one call to avoid race conditions
|
||||
await updateDbPicture(currentPicture.id, {
|
||||
status: 'objects_created',
|
||||
design: currentPicture.design ?? null,
|
||||
}, token)
|
||||
setPictureList(prev => prev.filter(p => p.id !== currentPicture.id))
|
||||
setCurrentIndex(i => Math.max(0, i - 1))
|
||||
setObjects([])
|
||||
@@ -419,14 +424,14 @@ export default function DrawIt() {
|
||||
value={currentPicture.design || ''}
|
||||
onChange={async e => {
|
||||
const value = e.target.value
|
||||
setPictureList(prev => prev.map(p => p.id === currentPicture.id ? { ...p, design: value || null } : p))
|
||||
const design = value || null
|
||||
setPictureList(prev => prev.map(p => p.id === currentPicture.id ? { ...p, design } : p))
|
||||
try {
|
||||
await fetch(`/api/directus/db-pictures/${currentPicture.id}`, {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json', Authorization: token ?? '' },
|
||||
body: JSON.stringify({ design: value || null }),
|
||||
})
|
||||
} catch (e) { console.error(e) }
|
||||
await updateDbPicture(currentPicture.id, { design }, token!)
|
||||
showStatus('Design gespeichert.')
|
||||
} catch (e) {
|
||||
showStatus('Fehler beim Speichern des Designs.', true)
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
width: '100%', padding: '6px 8px', borderRadius: 'var(--r-sm)',
|
||||
|
||||
Reference in New Issue
Block a user