Skip to content

Commit

Permalink
Fix: Every time you switch the page number of a chunk, the PDF docume…
Browse files Browse the repository at this point in the history
…nt will be reloaded. infiniflow#4046 (infiniflow#4047)

### What problem does this PR solve?

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

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
  • Loading branch information
cike8899 authored Dec 16, 2024
1 parent 7fb67c4 commit 8ea631a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
5 changes: 2 additions & 3 deletions web/src/hooks/chunk-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

0 comments on commit 8ea631a

Please sign in to comment.