Skip to content

Commit

Permalink
double check preview
Browse files Browse the repository at this point in the history
  • Loading branch information
dobri1408 committed Aug 22, 2024
1 parent c562940 commit 1579659
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/middlewares/preview_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export const preview_image = (middlewares) => [
? action?.request?.data.preview_image
: contentData?.preview_image;
const type = action?.request?.data?.['@type'] || contentData['@type'];
console.log(
lastPreviewImage,
type,
action?.request?.data?.tableau_visualization?.preview,
);

if (
!contentData ||
Expand All @@ -34,6 +39,7 @@ export const preview_image = (middlewares) => [
const tableauVisualizationData = {
...action.request.data.tableau_visualization,
};

if (
tableauVisualizationData.preview &&
tableauVisualizationData.preview_url_loaded
Expand Down Expand Up @@ -84,7 +90,25 @@ export const preview_image = (middlewares) => [
},
});
} catch (error) {
return next(action);
if (action.request.data.tableau_visualization.preview) {
const tableauVisualizationData = {
...action.request.data.tableau_visualization,
};
delete tableauVisualizationData.preview;
delete tableauVisualizationData.preview_url_loaded;

return next({
...action,
request: {
...action.request,
data: {
...action.request.data,
...previewImage,
tableau_visualization: tableauVisualizationData,
},
},
});
} else return next(action);
}
},
...middlewares,
Expand Down

0 comments on commit 1579659

Please sign in to comment.