diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsx index 4dcd247471e217..d83e6a4beaf6d2 100644 --- a/web/app/components/datasets/documents/list.tsx +++ b/web/app/components/datasets/documents/list.tsx @@ -2,6 +2,7 @@ 'use client' import type { FC, SVGProps } from 'react' import React, { useEffect, useState } from 'react' +import { useDebounceFn } from 'ahooks' import { ArrowDownIcon, TrashIcon } from '@heroicons/react/24/outline' import { ExclamationCircleIcon } from '@heroicons/react/24/solid' import dayjs from 'dayjs' @@ -154,6 +155,14 @@ export const OperationAction: FC<{ onUpdate(operationName) } + const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => { + if (operationName === 'enable' && enabled) + return + if (operationName === 'disable' && !enabled) + return + onOperate(operationName) + }, { wait: 500 }) + return
e.stopPropagation()}> {isListScene && !embeddingAvailable && ( { }} disabled={true} size='md' /> @@ -166,7 +175,7 @@ export const OperationAction: FC<{ { }} disabled={true} size='md' />
- : onOperate(v ? 'enable' : 'disable')} size='md' /> + : handleSwitch(v ? 'enable' : 'disable')} size='md' /> } @@ -189,7 +198,7 @@ export const OperationAction: FC<{
!archived && onOperate(v ? 'enable' : 'disable')} + onChange={v => !archived && handleSwitch(v ? 'enable' : 'disable')} disabled={archived} size='md' />