diff --git a/web/src/beta/lib/core/engines/Cesium/Feature/index.tsx b/web/src/beta/lib/core/engines/Cesium/Feature/index.tsx index 9e80c8a81e..1dab871273 100644 --- a/web/src/beta/lib/core/engines/Cesium/Feature/index.tsx +++ b/web/src/beta/lib/core/engines/Cesium/Feature/index.tsx @@ -90,20 +90,20 @@ export default function Feature({ const areAllDisplayTypeNoFeature = Array.isArray(displayType) && displayType.every(k => components[k][1].noFeature && !components[k][1].noLayer); + const cacheable = !data?.updateInterval; - const cachedRenderComponent = ( - k: keyof AppearanceTypes, - f?: ComputedFeature, - ): JSX.Element | null => { + const renderComponent = (k: keyof AppearanceTypes, f?: ComputedFeature): JSX.Element | null => { const componentId = generateIDWithMD5( `${layer.id}_${f?.id ?? ""}_${k}_${isHidden}_${data?.url ?? ""}_${ JSON.stringify(f?.[k]) ?? "" }`, ); - const cachedComponent = CACHED_COMPONENTS.get(componentId); - if (cachedComponent) { - return cachedComponent; + if (cacheable) { + const cachedComponent = CACHED_COMPONENTS.get(componentId); + if (cacheable && cachedComponent) { + return cachedComponent; + } } try { @@ -138,7 +138,9 @@ export default function Feature({ ); // Cache the component output - CACHED_COMPONENTS.set(componentId, component); + if (cacheable) { + CACHED_COMPONENTS.set(componentId, component); + } return component; } catch (e) { @@ -182,9 +184,7 @@ export default function Feature({ <> {cachedNoFeatureComponents || [undefined, ...layer.features].flatMap(f => - (Object.keys(components) as (keyof AppearanceTypes)[]).map(k => - cachedRenderComponent(k, f), - ), + (Object.keys(components) as (keyof AppearanceTypes)[]).map(k => renderComponent(k, f)), )} ); diff --git a/web/src/classic/core/engines/Cesium/Feature/index.tsx b/web/src/classic/core/engines/Cesium/Feature/index.tsx index 7a033f0114..687bc1fdae 100644 --- a/web/src/classic/core/engines/Cesium/Feature/index.tsx +++ b/web/src/classic/core/engines/Cesium/Feature/index.tsx @@ -90,20 +90,21 @@ export default function Feature({ const areAllDisplayTypeNoFeature = Array.isArray(displayType) && displayType.every(k => components[k][1].noFeature && !components[k][1].noLayer); + const cacheable = !data?.updateInterval; - const cachedRenderComponent = ( - k: keyof AppearanceTypes, - f?: ComputedFeature, - ): JSX.Element | null => { + const renderComponent = (k: keyof AppearanceTypes, f?: ComputedFeature): JSX.Element | null => { const componentId = generateIDWithMD5( `${layer.id}_${f?.id ?? ""}_${k}_${isHidden}_${data?.url ?? ""}_${ JSON.stringify(f?.[k]) ?? "" }`, ); - const cachedComponent = CACHED_COMPONENTS.get(componentId); - if (cachedComponent) { - return cachedComponent; + if (cacheable) { + const cachedComponent = CACHED_COMPONENTS.get(componentId); + + if (cachedComponent) { + return cachedComponent; + } } try { @@ -138,7 +139,9 @@ export default function Feature({ ); // Cache the component output - CACHED_COMPONENTS.set(componentId, component); + if (cacheable) { + CACHED_COMPONENTS.set(componentId, component); + } return component; } catch (e) { @@ -182,9 +185,7 @@ export default function Feature({ <> {cachedNoFeatureComponents || [undefined, ...layer.features].flatMap(f => - (Object.keys(components) as (keyof AppearanceTypes)[]).map(k => - cachedRenderComponent(k, f), - ), + (Object.keys(components) as (keyof AppearanceTypes)[]).map(k => renderComponent(k, f)), )} );