fix loadInitData refresh (#4169)
* fix * fix * form input number default & api dataset max token
This commit is contained in:
@@ -34,13 +34,13 @@ export function useLinkedScroll<
|
||||
bottom: null as { _id: string; index: number } | null
|
||||
});
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const itemRefs = useRef<(HTMLElement | null)[]>([]);
|
||||
const itemRefs = useRef<Map<string, HTMLElement | null>>(new Map());
|
||||
|
||||
const scrollToItem = async (id: string, retry = 3) => {
|
||||
const itemIndex = dataList.findIndex((item) => item._id === id);
|
||||
if (itemIndex === -1) return;
|
||||
|
||||
const element = itemRefs.current[itemIndex];
|
||||
const element = itemRefs.current.get(id);
|
||||
|
||||
if (!element || !containerRef.current) {
|
||||
if (retry > 0) {
|
||||
@@ -64,7 +64,8 @@ export function useLinkedScroll<
|
||||
|
||||
let scroolSign = useRef(false);
|
||||
const { runAsync: loadInitData } = useRequest2(
|
||||
async (scrollWhenFinish = true, refresh = false) => {
|
||||
async ({ scrollWhenFinish, refresh } = { scrollWhenFinish: true, refresh: false }) => {
|
||||
console.log('loadInitData', params);
|
||||
if (!currentData || isLoading) return;
|
||||
|
||||
const item = dataList.find((item) => item._id === currentData.id);
|
||||
|
||||
@@ -299,6 +299,7 @@ const RenderUserFormInteractive = React.memo(function RenderFormInput({
|
||||
<MyNumberInput
|
||||
min={input.min}
|
||||
max={input.max}
|
||||
defaultValue={input.defaultValue}
|
||||
isDisabled={interactive.params.submitted}
|
||||
bg={'white'}
|
||||
register={register}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { useCopyData } from '@fastgpt/web/hooks/useCopyData';
|
||||
import InputDataModal from '@/pageComponents/dataset/detail/InputDataModal';
|
||||
|
||||
const CollectionQuoteItem = ({
|
||||
index,
|
||||
quoteRefs,
|
||||
quoteIndex,
|
||||
setQuoteIndex,
|
||||
@@ -22,8 +21,7 @@ const CollectionQuoteItem = ({
|
||||
dataId,
|
||||
collectionId
|
||||
}: {
|
||||
index: number;
|
||||
quoteRefs: MutableRefObject<(HTMLDivElement | null)[]>;
|
||||
quoteRefs: MutableRefObject<Map<string, HTMLDivElement | null>>;
|
||||
quoteIndex: number;
|
||||
setQuoteIndex: Dispatch<SetStateAction<number>>;
|
||||
refreshList: () => void;
|
||||
@@ -45,7 +43,7 @@ const CollectionQuoteItem = ({
|
||||
<>
|
||||
<Box
|
||||
ref={(el: HTMLDivElement | null) => {
|
||||
quoteRefs.current[index] = el;
|
||||
quoteRefs.current.set(dataId, el);
|
||||
}}
|
||||
p={2}
|
||||
py={2}
|
||||
@@ -163,9 +161,7 @@ const CollectionQuoteItem = ({
|
||||
'0px 1px 2px 0px rgba(19, 51, 107, 0.05), 0px 0px 1px 0px rgba(19, 51, 107, 0.08)'
|
||||
}
|
||||
cursor={'pointer'}
|
||||
onClick={() => {
|
||||
copyData(q + '\n' + a);
|
||||
}}
|
||||
onClick={() => copyData(`${q}${a ? '\n' + a : ''}`)}
|
||||
>
|
||||
<MyIcon name="copy" w={'14px'} color={'myGray.500'} />
|
||||
</Flex>
|
||||
|
||||
@@ -256,11 +256,10 @@ const CollectionReader = ({
|
||||
{formatedDataList.map((item, index) => (
|
||||
<CollectionQuoteItem
|
||||
key={item._id}
|
||||
index={index}
|
||||
quoteRefs={itemRefs as React.MutableRefObject<(HTMLDivElement | null)[]>}
|
||||
quoteRefs={itemRefs as React.MutableRefObject<Map<string, HTMLDivElement | null>>}
|
||||
quoteIndex={item.quoteIndex}
|
||||
setQuoteIndex={setQuoteIndex}
|
||||
refreshList={() => loadInitData(false, true)}
|
||||
refreshList={() => loadInitData({ scrollWhenFinish: false, refresh: true })}
|
||||
updated={item.updated}
|
||||
isCurrentSelected={item.isCurrentSelected}
|
||||
q={item.q}
|
||||
|
||||
@@ -60,7 +60,7 @@ const ApiDatasetForm = ({
|
||||
<Input
|
||||
bg={'myWhite.600'}
|
||||
placeholder={t('dataset:request_headers')}
|
||||
maxLength={200}
|
||||
maxLength={2000}
|
||||
{...register('apiServer.authorization')}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
Reference in New Issue
Block a user