Skip to content

Commit e0267ed

Browse files
committed
CLIM-1291: Extract named booleans for layer guard
shouldHideLayer = !isForecast || isLowSkillMasked hasLayerData = layerName && timeValue
1 parent 8b251dd commit e0267ed

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

apps/src/components/map-layers/low-skill-layer.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const LowSkillLayer = ({
3636
timeValue = buildSkillLayerTime(climateVariable, releaseDate);
3737
}
3838

39+
const hasLayerData = layerName && timeValue;
40+
const shouldHideLayer = !isForecast || isLowSkillMasked;
41+
3942
// Update the opacity on the *existing* layer if it exists. We do it like
4043
// that because we don't want a change in opacity to recreate the layer.
4144
// Instead, we want to update the existing layer (else it creates flashing
@@ -52,12 +55,7 @@ const LowSkillLayer = ({
5255
// attributes change.
5356
return useMemo(
5457
() => {
55-
if (
56-
!isForecast
57-
|| isLowSkillMasked
58-
|| !layerName
59-
|| !timeValue
60-
) {
58+
if (shouldHideLayer || !hasLayerData) {
6159
return null;
6260
}
6361

@@ -87,10 +85,9 @@ const LowSkillLayer = ({
8785
//
8886
// eslint-disable-next-line react-hooks/exhaustive-deps
8987
[
90-
isForecast,
91-
isLowSkillMasked,
9288
layerName,
9389
pane,
90+
shouldHideLayer,
9491
timeValue,
9592
]
9693
);

0 commit comments

Comments
 (0)