balibabu commited on
Commit
7056954
·
1 Parent(s): 69ced1e

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

Browse files

### 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)

web/src/hooks/chunk-hooks.ts CHANGED
@@ -45,9 +45,8 @@ export const useFetchNextChunkList = (): ResponseGetType<{
45
  debouncedSearchString,
46
  available,
47
  ],
48
-
49
- initialData: { data: [], total: 0, documentInfo: {} },
50
- // placeholderData: keepPreviousData,
51
  gcTime: 0,
52
  queryFn: async () => {
53
  const { data } = await kbService.chunk_list({
 
45
  debouncedSearchString,
46
  available,
47
  ],
48
+ placeholderData: (previousData) =>
49
+ previousData ?? { data: [], total: 0, documentInfo: {} }, // https://github.com/TanStack/query/issues/8183
 
50
  gcTime: 0,
51
  queryFn: async () => {
52
  const { data } = await kbService.chunk_list({
web/src/pages/add-knowledge/components/knowledge-chunk/components/document-preview/preview.tsx CHANGED
@@ -32,7 +32,6 @@ const HighlightPopup = ({
32
  // TODO: merge with DocumentPreviewer
33
  const Preview = ({ highlights: state, setWidthAndHeight }: IProps) => {
34
  const url = useGetDocumentUrl();
35
- useCatchDocumentError(url);
36
 
37
  const ref = useRef<(highlight: IHighlight) => void>(() => {});
38
  const error = useCatchDocumentError(url);
@@ -119,12 +118,4 @@ const Preview = ({ highlights: state, setWidthAndHeight }: IProps) => {
119
  );
120
  };
121
 
122
- const compare = (oldProps: IProps, newProps: IProps) => {
123
- const arePropsEqual =
124
- oldProps.highlights === newProps.highlights ||
125
- (oldProps.highlights.length === 0 && newProps.highlights.length === 0);
126
-
127
- return arePropsEqual;
128
- };
129
-
130
  export default memo(Preview);
 
32
  // TODO: merge with DocumentPreviewer
33
  const Preview = ({ highlights: state, setWidthAndHeight }: IProps) => {
34
  const url = useGetDocumentUrl();
 
35
 
36
  const ref = useRef<(highlight: IHighlight) => void>(() => {});
37
  const error = useCatchDocumentError(url);
 
118
  );
119
  };
120
 
 
 
 
 
 
 
 
 
121
  export default memo(Preview);