mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
fix(kb): align bulk chunk operation with API response (#2899)
* fix(kb): align bulk chunk operation with API response * fix(kb): skip local state update for failed chunks * fix(kb): correct errors type and refresh on partial failure
This commit is contained in:
@@ -538,15 +538,11 @@ export function Document({
|
||||
},
|
||||
{
|
||||
onSuccess: (result) => {
|
||||
if (operation === 'delete') {
|
||||
if (operation === 'delete' || result.errorCount > 0) {
|
||||
refreshChunks()
|
||||
} else {
|
||||
result.results.forEach((opResult) => {
|
||||
if (opResult.operation === operation) {
|
||||
opResult.chunkIds.forEach((chunkId: string) => {
|
||||
updateChunk(chunkId, { enabled: operation === 'enable' })
|
||||
})
|
||||
}
|
||||
chunks.forEach((chunk) => {
|
||||
updateChunk(chunk.id, { enabled: operation === 'enable' })
|
||||
})
|
||||
}
|
||||
logger.info(`Successfully ${operation}d ${result.successCount} chunks`)
|
||||
|
||||
@@ -755,12 +755,11 @@ export interface BulkChunkOperationParams {
|
||||
}
|
||||
|
||||
export interface BulkChunkOperationResult {
|
||||
operation: string
|
||||
successCount: number
|
||||
failedCount: number
|
||||
results: Array<{
|
||||
operation: string
|
||||
chunkIds: string[]
|
||||
}>
|
||||
errorCount: number
|
||||
processed: number
|
||||
errors: string[]
|
||||
}
|
||||
|
||||
export async function bulkChunkOperation({
|
||||
|
||||
Reference in New Issue
Block a user