From e6c819ea8d87b59d074660bdacaf69bbe6c37c6e Mon Sep 17 00:00:00 2001 From: vashjs Date: Sun, 27 Oct 2024 08:22:28 +0100 Subject: [PATCH] invalidate query after preview loaded --- .../BulkEditInAppPreviewModal/BulkEditPreviewModalList.js | 6 +++++- src/components/shared/ProgressBar/ProgressBar.js | 1 - src/hooks/useConfirmChanges.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js index ee0d4c0b..2ee5cd9e 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js @@ -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'; @@ -23,6 +24,7 @@ import { PAGINATION_CONFIG } from '../../../../constants'; import { + BULK_OPERATION_DETAILS_KEY, PREVIEW_MODAL_KEY, useBulkOperationDetails, useRecordsPreview @@ -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(); @@ -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); @@ -70,6 +73,7 @@ export const BulkEditPreviewModalList = ({ }, onSettled: () => { setPreviewLoaded(true); + queryClient.invalidateQueries(BULK_OPERATION_DETAILS_KEY); } }, ...pagination, diff --git a/src/components/shared/ProgressBar/ProgressBar.js b/src/components/shared/ProgressBar/ProgressBar.js index f3e6325d..f764ff48 100644 --- a/src/components/shared/ProgressBar/ProgressBar.js +++ b/src/components/shared/ProgressBar/ProgressBar.js @@ -49,7 +49,6 @@ export const ProgressBar = () => { bulkDetails, id, clearIntervalAndRedirect, - showErrorMessage, ]); return ( diff --git a/src/hooks/useConfirmChanges.js b/src/hooks/useConfirmChanges.js index 006cec79..72397fe6 100644 --- a/src/hooks/useConfirmChanges.js +++ b/src/hooks/useConfirmChanges.js @@ -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);