Skip to content

Commit

Permalink
fix: reduce number of calls for print action (#816)
Browse files Browse the repository at this point in the history
RM#87597
  • Loading branch information
lme-axelor authored Nov 28, 2024
1 parent 9119db3 commit bfa318e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelogs/unreleased/87597.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"title": "Print header action: check if a template exists only when model and id are present",
"type": "fix",
"packages": "core"
}
12 changes: 7 additions & 5 deletions packages/core/src/header/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ export const useBasicActions = ({
}, [model]);

useEffect(() => {
fetchActionPrint({model, id: modelId})
.catch(() => setDisablePrinting(true))
.then(({templateSet, fileName}) => {
setDisablePrinting(templateSet == null && fileName == null);
});
if (model && modelId) {
fetchActionPrint({model, id: modelId})
.catch(() => setDisablePrinting(true))
.then(({templateSet, fileName}) => {
setDisablePrinting(templateSet == null && fileName == null);
});
}
}, [model, modelId]);

const checkInternetConnection = useCallback(async () => {
Expand Down

0 comments on commit bfa318e

Please sign in to comment.