mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-19 20:16:49 +08:00
fix: disable sending messages if both application and conversation are empty and add loading to all pages (#134)
* feat: add loading to all pages * fix: disable sending messages if both application and conversation are empty * feat: add chatSpin class to Spin of chat
This commit is contained in:
24
web/src/hooks/chunkHooks.ts
Normal file
24
web/src/hooks/chunkHooks.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useDispatch } from 'umi';
|
||||
import { useGetKnowledgeSearchParams } from './routeHook';
|
||||
|
||||
interface PayloadType {
|
||||
doc_id: string;
|
||||
keywords?: string;
|
||||
}
|
||||
|
||||
export const useFetchChunkList = () => {
|
||||
const dispatch = useDispatch();
|
||||
const { documentId } = useGetKnowledgeSearchParams();
|
||||
|
||||
const fetchChunkList = useCallback(() => {
|
||||
dispatch({
|
||||
type: 'chunkModel/chunk_list',
|
||||
payload: {
|
||||
doc_id: documentId,
|
||||
},
|
||||
});
|
||||
}, [dispatch, documentId]);
|
||||
|
||||
return fetchChunkList;
|
||||
};
|
||||
@ -1,8 +1,9 @@
|
||||
import showDeleteConfirm from '@/components/deleting-confirm';
|
||||
import { KnowledgeSearchParams } from '@/constants/knowledge';
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import { useCallback, useEffect, useMemo } from 'react';
|
||||
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
||||
import { useGetKnowledgeSearchParams } from './routeHook';
|
||||
import { useOneNamespaceEffectsLoading } from './storeHooks';
|
||||
|
||||
export const useKnowledgeBaseId = (): string => {
|
||||
const [searchParams] = useSearchParams();
|
||||
@ -11,17 +12,6 @@ export const useKnowledgeBaseId = (): string => {
|
||||
return knowledgeBaseId || '';
|
||||
};
|
||||
|
||||
export const useGetKnowledgeSearchParams = () => {
|
||||
const [currentQueryParameters] = useSearchParams();
|
||||
|
||||
return {
|
||||
documentId:
|
||||
currentQueryParameters.get(KnowledgeSearchParams.DocumentId) || '',
|
||||
knowledgeId:
|
||||
currentQueryParameters.get(KnowledgeSearchParams.KnowledgeId) || '',
|
||||
};
|
||||
};
|
||||
|
||||
export const useDeleteDocumentById = (): {
|
||||
removeDocument: (documentId: string) => Promise<number>;
|
||||
} => {
|
||||
@ -135,8 +125,9 @@ export const useFetchKnowledgeBaseConfiguration = () => {
|
||||
|
||||
export const useFetchKnowledgeList = (
|
||||
shouldFilterListWithoutDocument: boolean = false,
|
||||
): IKnowledge[] => {
|
||||
): { list: IKnowledge[]; loading: boolean } => {
|
||||
const dispatch = useDispatch();
|
||||
const loading = useOneNamespaceEffectsLoading('knowledgeModel', ['getList']);
|
||||
|
||||
const knowledgeModel = useSelector((state: any) => state.knowledgeModel);
|
||||
const { data = [] } = knowledgeModel;
|
||||
@ -156,7 +147,7 @@ export const useFetchKnowledgeList = (
|
||||
fetchList();
|
||||
}, [fetchList]);
|
||||
|
||||
return list;
|
||||
return { list, loading };
|
||||
};
|
||||
|
||||
export const useSelectFileThumbnails = () => {
|
||||
@ -189,3 +180,29 @@ export const useFetchFileThumbnails = (docIds?: Array<string>) => {
|
||||
|
||||
return { fileThumbnails, fetchFileThumbnails };
|
||||
};
|
||||
|
||||
//#region knowledge configuration
|
||||
|
||||
export const useUpdateKnowledge = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const saveKnowledgeConfiguration = useCallback(
|
||||
(payload: any) => {
|
||||
dispatch({
|
||||
type: 'kSModel/updateKb',
|
||||
payload,
|
||||
});
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
return saveKnowledgeConfiguration;
|
||||
};
|
||||
|
||||
export const useSelectKnowledgeDetails = () => {
|
||||
const knowledgeDetails: IKnowledge = useSelector(
|
||||
(state: any) => state.kSModel.knowledgeDetails,
|
||||
);
|
||||
return knowledgeDetails;
|
||||
};
|
||||
//#endregion
|
||||
|
||||
@ -8,8 +8,8 @@ import { useCallback, useEffect, useMemo } from 'react';
|
||||
import { useDispatch, useSelector } from 'umi';
|
||||
|
||||
export const useFetchLlmList = (
|
||||
isOnMountFetching: boolean = true,
|
||||
modelType?: LlmModelType,
|
||||
isOnMountFetching: boolean = true,
|
||||
) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { useLocation } from 'umi';
|
||||
import { KnowledgeSearchParams } from '@/constants/knowledge';
|
||||
import { useLocation, useSearchParams } from 'umi';
|
||||
|
||||
export enum SegmentIndex {
|
||||
Second = '2',
|
||||
@ -19,3 +20,14 @@ export const useSecondPathName = () => {
|
||||
export const useThirdPathName = () => {
|
||||
return useSegmentedPathName(SegmentIndex.Third);
|
||||
};
|
||||
|
||||
export const useGetKnowledgeSearchParams = () => {
|
||||
const [currentQueryParameters] = useSearchParams();
|
||||
|
||||
return {
|
||||
documentId:
|
||||
currentQueryParameters.get(KnowledgeSearchParams.DocumentId) || '',
|
||||
knowledgeId:
|
||||
currentQueryParameters.get(KnowledgeSearchParams.KnowledgeId) || '',
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user