Fix: Every time you switch the page number of a chunk, the PDF document will be reloaded. #4046 (#4047)

### What problem does this PR solve?

Fix: Every time you switch the page number of a chunk, the PDF document
will be reloaded. #4046

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu 2024-12-16 18:51:45 +08:00 committed by GitHub
parent 7fb67c4f67
commit 8ea631a2a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 12 deletions

View File

@ -45,9 +45,8 @@ export const useFetchNextChunkList = (): ResponseGetType<{
debouncedSearchString,
available,
],
initialData: { data: [], total: 0, documentInfo: {} },
// placeholderData: keepPreviousData,
placeholderData: (previousData) =>
previousData ?? { data: [], total: 0, documentInfo: {} }, // https://github.com/TanStack/query/issues/8183
gcTime: 0,
queryFn: async () => {
const { data } = await kbService.chunk_list({

View File

@ -32,7 +32,6 @@ const HighlightPopup = ({
// TODO: merge with DocumentPreviewer
const Preview = ({ highlights: state, setWidthAndHeight }: IProps) => {
const url = useGetDocumentUrl();
useCatchDocumentError(url);
const ref = useRef<(highlight: IHighlight) => void>(() => {});
const error = useCatchDocumentError(url);
@ -119,12 +118,4 @@ const Preview = ({ highlights: state, setWidthAndHeight }: IProps) => {
);
};
const compare = (oldProps: IProps, newProps: IProps) => {
const arePropsEqual =
oldProps.highlights === newProps.highlights ||
(oldProps.highlights.length === 0 && newProps.highlights.length === 0);
return arePropsEqual;
};
export default memo(Preview);