fix: correct updateAssistantPreset reducer to properly update preset (#11453)

The previous implementation used `a = preset` inside forEach, which only
reassigns the local variable and doesn't actually update the array element.

Changed to use findIndex + direct array assignment to properly update
the preset in the state.

Fixes #11451

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
fullex 2025-11-25 20:59:56 +08:00 committed by GitHub
parent bcd7bc9f2d
commit fd3b7f717d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -202,11 +202,10 @@ const assistantsSlice = createSlice({
},
updateAssistantPreset: (state, action: PayloadAction<AssistantPreset>) => {
const preset = action.payload
state.presets.forEach((a) => {
if (a.id === preset.id) {
a = preset
}
})
const index = state.presets.findIndex((a) => a.id === preset.id)
if (index !== -1) {
state.presets[index] = preset
}
},
updateAssistantPresetSettings: (
state,