Skip to content

Commit ce6e883

Browse files
committed
added resetMutation calls after modal closes
1 parent 51af1b5 commit ce6e883

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/components/create-chunk-modal/create-chunk-modal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ export function CreateChunkModal({
3030
document,
3131
knowledgeBaseId,
3232
}: CreateChunkModalProps) {
33-
const { mutate: createChunk, isPending: isCreating, error: mutationError } = useCreateChunk()
33+
const {
34+
mutate: createChunk,
35+
isPending: isCreating,
36+
error: mutationError,
37+
reset: resetMutation,
38+
} = useCreateChunk()
3439
const [content, setContent] = useState('')
3540
const [showUnsavedChangesAlert, setShowUnsavedChangesAlert] = useState(false)
3641
const isProcessingRef = useRef(false)
@@ -71,6 +76,7 @@ export function CreateChunkModal({
7176
onOpenChange(false)
7277
setContent('')
7378
setShowUnsavedChangesAlert(false)
79+
resetMutation()
7480
}
7581

7682
const handleCloseAttempt = () => {

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/components/edit-chunk-modal/edit-chunk-modal.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ export function EditChunkModal({
5050
maxChunkSize,
5151
}: EditChunkModalProps) {
5252
const userPermissions = useUserPermissionsContext()
53-
const { mutate: updateChunk, isPending: isSaving, error: mutationError } = useUpdateChunk()
53+
const {
54+
mutate: updateChunk,
55+
isPending: isSaving,
56+
error: mutationError,
57+
reset: resetMutation,
58+
} = useUpdateChunk()
5459
const [editedContent, setEditedContent] = useState(chunk?.content || '')
5560
const [isNavigating, setIsNavigating] = useState(false)
5661
const [showUnsavedChangesAlert, setShowUnsavedChangesAlert] = useState(false)
@@ -154,6 +159,7 @@ export function EditChunkModal({
154159
setPendingNavigation(null)
155160
setShowUnsavedChangesAlert(true)
156161
} else {
162+
resetMutation()
157163
onClose()
158164
}
159165
}
@@ -164,6 +170,7 @@ export function EditChunkModal({
164170
void pendingNavigation()
165171
setPendingNavigation(null)
166172
} else {
173+
resetMutation()
167174
onClose()
168175
}
169176
}

0 commit comments

Comments
 (0)