Skip to content

Commit

Permalink
invalidate query after preview loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 27, 2024
1 parent e5d485b commit e6c819e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@folio/stripes-acq-components';

import { Preloader } from '@folio/stripes-data-transfer-components';
import { useQueryClient } from 'react-query';
import { PREVIEW_COLUMN_WIDTHS } from '../../../PermissionsModal/constants/lists';
import css from './BulkEditInAppPreviewModal.css';
import { usePagination } from '../../../../hooks/usePagination';
Expand All @@ -23,6 +24,7 @@ import {
PAGINATION_CONFIG
} from '../../../../constants';
import {
BULK_OPERATION_DETAILS_KEY,
PREVIEW_MODAL_KEY,
useBulkOperationDetails,
useRecordsPreview
Expand All @@ -37,6 +39,7 @@ export const BulkEditPreviewModalList = ({
isPreviewEnabled,
onPreviewError,
}) => {
const queryClient = useQueryClient();
const { id: bulkOperationId } = usePathParams('/bulk-edit/:id');
const { visibleColumns } = useContext(RootContext);
const { currentRecordType } = useSearchParams();
Expand All @@ -48,7 +51,7 @@ export const BulkEditPreviewModalList = ({

const [previewLoaded, setPreviewLoaded] = useState(false);
const interval = previewLoaded ? 0 : 3000;
const { bulkDetails } = useBulkOperationDetails({ id: bulkOperationId, interval, refetchOnMount: true });
const { bulkDetails } = useBulkOperationDetails({ id: bulkOperationId, interval });

const visibleColumnKeys = getVisibleColumnsKeys(visibleColumns);

Expand All @@ -70,6 +73,7 @@ export const BulkEditPreviewModalList = ({
},
onSettled: () => {
setPreviewLoaded(true);
queryClient.invalidateQueries(BULK_OPERATION_DETAILS_KEY);
}
},
...pagination,
Expand Down
1 change: 0 additions & 1 deletion src/components/shared/ProgressBar/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const ProgressBar = () => {
bulkDetails,
id,
clearIntervalAndRedirect,
showErrorMessage,
]);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useConfirmChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useConfirmChanges = ({
// we need to set it manually to show the preview modal without a delay
queryClient.setQueryData(
[BULK_OPERATION_DETAILS_KEY, namespaceKey, bulkOperationId],
(preBulkOperation) => ({ ...preBulkOperation, status: JOB_STATUSES.DATA_MODIFICATION })
(preBulkOperation) => ({ ...preBulkOperation, status: JOB_STATUSES.DATA_MODIFICATION }),
);

setIsPreviewModalOpened(true);
Expand Down

0 comments on commit e6c819e

Please sign in to comment.