fix: Bulk disable the chunk, the UI still shows they are enabled #1236 (#1534)

### What problem does this PR solve?
fix: Bulk disable the chunk, the UI still shows they are enabled #1236

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu 2024-07-16 15:26:41 +08:00 committed by GitHub
parent 75086f41a9
commit 266119bf62
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,7 +3,7 @@ import { IChunk } from '@/interfaces/database/knowledge';
import { Card, Checkbox, CheckboxProps, Flex, Popover, Switch } from 'antd';
import classNames from 'classnames';
import DOMPurify from 'dompurify';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { ChunkTextMode } from '../../constant';
import styles from './index.less';
@ -30,7 +30,7 @@ const ChunkCard = ({
textMode,
}: IProps) => {
const available = Number(item.available_int);
const [enabled, setEnabled] = useState(available === 1);
const [enabled, setEnabled] = useState(false);
const onChange = (checked: boolean) => {
setEnabled(checked);
@ -49,6 +49,10 @@ const ChunkCard = ({
clickChunkCard(item.chunk_id);
};
useEffect(() => {
setEnabled(available === 1);
}, [available]);
return (
<Card
className={classNames(styles.chunkCard, {