Compare commits

..

5 Commits

Author SHA1 Message Date
Tim Leikauf
860391bcbe Merge: Level-Update + Picture-Link für bestehende Wörter 2026-05-06 21:30:41 +02:00
Tim Leikauf
cc782c0ef0 fix(words): bestehendes Wort → Level updaten + Picture-Link immer setzen
_find_or_create_word gibt is_new zurück; bei is_new=False wird das Level
via PATCH aktualisiert. _ensure_link läuft immer → Picture-Junction wird
auch für bereits existierende Wörter angelegt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 21:30:41 +02:00
Tim Leikauf
9acc1d93b4 Merge: Bildnavigation debounce fix 2026-05-06 21:29:16 +02:00
Tim Leikauf
08cce17976 fix(draw): Bildnavigation debounce – nur letztes Bild laden bei schnellem Weiterklicken
currentPicture folgt debouncedIndex (350ms), currentIndex reagiert sofort
für Counter und Button-Disabled-State.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-06 21:28:11 +02:00
Tim Leikauf
202d4333a8 Merge: Words-Frame mit Level per Bild (Safe Words → Directus) 2026-05-06 21:22:43 +02:00
2 changed files with 13 additions and 2 deletions

5
app.py
View File

@@ -157,7 +157,10 @@ def directus_picture_words(pic_id):
if not title_de:
continue
try:
wid, _ = _find_or_create_word(title_de, level, token)
wid, is_new = _find_or_create_word(title_de, level, token)
if not is_new:
# Wort existiert bereits → Level aktualisieren
_directus("PATCH", f"/items/words/{wid}", token, {"level": level})
_ensure_link(
"words_pictures",
{"words_id": wid, "pictures_id": pic_id},

View File

@@ -30,6 +30,7 @@ export default function DrawIt() {
const [pictureList, setPictureList] = useState<DirectusPicture[]>([])
const [currentIndex, setCurrentIndex] = useState(-1)
const [debouncedIndex, setDebouncedIndex] = useState(-1)
const [objects, setObjects] = useState<DirectusObject[]>([])
const [selectedObjectId, setSelectedObjectId] = useState<string | null>(null)
const [currentSelections, setCurrentSelections] = useState<Selection[]>([])
@@ -52,6 +53,12 @@ export default function DrawIt() {
const canvasRef = useRef<DrawCanvasHandle>(null)
// Debounce: Bild erst laden wenn 350ms keine weitere Navigation
useEffect(() => {
const t = setTimeout(() => setDebouncedIndex(currentIndex), 350)
return () => clearTimeout(t)
}, [currentIndex])
useEffect(() => {
if (safeWordInputVisible) safeWordInputRef.current?.focus()
}, [safeWordInputVisible])
@@ -83,8 +90,9 @@ export default function DrawIt() {
}
}
// currentPicture folgt dem debouncedIndex → lädt erst wenn Navigation pausiert
const currentPicture: DirectusPicture | null =
currentIndex >= 0 && currentIndex < pictureList.length ? pictureList[currentIndex] : null
debouncedIndex >= 0 && debouncedIndex < pictureList.length ? pictureList[debouncedIndex] : null
// Map DirectusObject → CanvasObject for rendering
const canvasObjects: CanvasObject[] = objects.map((obj, i) => ({