From 9f1d2915696797ededd62d4bd1aa7c0aace6bd9b Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Wed, 19 Jun 2024 15:20:05 +0200 Subject: [PATCH] fix: only use cache if plugin has PWA enabled --- .../DashboardPluginWrapper.js | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/components/DashboardPluginWrapper/DashboardPluginWrapper.js b/src/components/DashboardPluginWrapper/DashboardPluginWrapper.js index efb85f816..52796cbcf 100644 --- a/src/components/DashboardPluginWrapper/DashboardPluginWrapper.js +++ b/src/components/DashboardPluginWrapper/DashboardPluginWrapper.js @@ -1,4 +1,8 @@ -import { useCacheableSection, CacheableSection } from '@dhis2/app-runtime' +import { + useCacheableSection, + CacheableSection, + useConfig, +} from '@dhis2/app-runtime' import { CenteredContent, CircularLoader, CssVariables, Layer } from '@dhis2/ui' import PropTypes from 'prop-types' import React, { useEffect } from 'react' @@ -51,6 +55,8 @@ export const DashboardPluginWrapper = ({ isParentCached, ...props }) => { + const { pwaEnabled } = useConfig() + useEffect(() => { // Get & send PWA installation status now getPWAInstallationStatus({ @@ -66,20 +72,28 @@ export const DashboardPluginWrapper = ({ overflow: 'hidden', }} > - - {children(props)} - + {pwaEnabled ? ( + + {children(props)} + + ) : ( + children(props) + )} ) : null } +DashboardPluginWrapper.defaultProps = { + onInstallationStatusChange: Function.prototype, +} + DashboardPluginWrapper.propTypes = { - cacheId: PropTypes.string, - children: PropTypes.func, - isParentCached: PropTypes.bool, + cacheId: PropTypes.string.isRequired, + children: PropTypes.func.isRequired, + isParentCached: PropTypes.bool.isRequired, onInstallationStatusChange: PropTypes.func, }