mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 11:20:07 +08:00
fix(store): ignore ts-2589 false positives and refactor preset updates
Refactor assistant preset updates to use forEach instead of map for consistency Add ts-ignore comments for TypeScript false positives in store operations
This commit is contained in:
parent
f25142e597
commit
4e26291a61
@ -19,16 +19,26 @@ const assistantsSlice = createSlice({
|
||||
initialState,
|
||||
reducers: {
|
||||
setAssistantPresets: (state, action: PayloadAction<AssistantPreset[]>) => {
|
||||
state.agents = { ...action.payload }
|
||||
const presets = action.payload
|
||||
state.agents = []
|
||||
presets.forEach((p) => {
|
||||
state.agents.push(p)
|
||||
})
|
||||
},
|
||||
addAssistantPreset: (state, action: PayloadAction<AssistantPreset>) => {
|
||||
// @ts-ignore ts-2589 false positive
|
||||
state.agents.push(action.payload)
|
||||
},
|
||||
removeAssistantPreset: (state, action: PayloadAction<{ id: string }>) => {
|
||||
state.agents = state.agents.filter((c) => c.id !== action.payload.id)
|
||||
},
|
||||
updateAssistantPreset: (state, action: PayloadAction<AssistantPreset>) => {
|
||||
state.agents = state.agents.map((c) => (c.id === action.payload.id ? action.payload : c))
|
||||
const preset = action.payload
|
||||
state.agents.forEach((a) => {
|
||||
if (a.id === preset.id) {
|
||||
a = preset
|
||||
}
|
||||
})
|
||||
},
|
||||
updateAssistantPresetSettings: (
|
||||
state,
|
||||
|
||||
@ -102,6 +102,7 @@ export const messagesSlice = createSlice({
|
||||
},
|
||||
messagesReceived(state, action: PayloadAction<MessagesReceivedPayload>) {
|
||||
const { topicId, messages } = action.payload
|
||||
// @ts-ignore ts-2589 false positive
|
||||
messagesAdapter.upsertMany(state, messages)
|
||||
state.messageIdsByTopic[topicId] = messages.map((m) => m.id)
|
||||
state.currentTopicId = topicId
|
||||
|
||||
@ -150,6 +150,7 @@ const runtimeSlice = createSlice({
|
||||
state.chat.selectedMessageIds = action.payload
|
||||
},
|
||||
setActiveTopic: (state, action: PayloadAction<Topic>) => {
|
||||
// @ts-ignore ts2589 false positive
|
||||
state.chat.activeTopic = action.payload
|
||||
},
|
||||
setActiveAgentId: (state, action: PayloadAction<string>) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user