fix: ensure the user can select any image in NewApiPage (#11238)

NewApiPage always show the first image in filteredPaintings. As a
result, the user is unable to select other images. This issue was
introduced in commit 0502ff4.
This commit is contained in:
Xiang, Haihao 2025-11-12 13:30:23 +08:00 committed by GitHub
parent 803f4b5a64
commit 2552d97ea7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -472,9 +472,15 @@ const NewApiPage: FC<{ Options: string[] }> = ({ Options }) => {
addPainting(mode, newPainting) addPainting(mode, newPainting)
setPainting(newPainting) setPainting(newPainting)
} else { } else {
setPainting(filteredPaintings[0]) // 如果当前 painting 存在于 filteredPaintings 中,则优先显示当前 painting
const found = filteredPaintings.find((p) => p.id === painting.id)
if (found) {
setPainting(found)
} else {
setPainting(filteredPaintings[0])
}
} }
}, [filteredPaintings, mode, addPainting, getNewPainting]) }, [filteredPaintings, mode, addPainting, getNewPainting, painting.id])
useEffect(() => { useEffect(() => {
const timer = spaceClickTimer.current const timer = spaceClickTimer.current