Skip to content

Commit

Permalink
[fix] setFeatureStyle파일에서 isChanged검사가 빠져있어서 추가
Browse files Browse the repository at this point in the history
- setFeatureStyle파일에서 isChanged검사가 빠져있어서 변화 없음에도 실행되는 경우 발생
- isChanged를 추가하고 init일 때를 대비해서 검사 조건을 추가함
  • Loading branch information
qkrdmstlr3 committed Dec 14, 2020
1 parent 5c7a86d commit 90ca64b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils/setFeatureStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ function setFeatureStyle({
if (featureState[x].isChanged || !featureState[y].isChanged) return 1;
return -1;
});
const isInit =
subFeatures.findIndex(
(subFeature) => featureState[subFeature].isChanged
) === -1;

for (const subFeature of sortedFeatures) {
const elements = Object.keys(featureState[subFeature]) as ElementNameType[];
Expand All @@ -42,6 +46,7 @@ function setFeatureStyle({
subFeature,
element,
style: elementStyle as StyleType,
isInit,
});
break;
case ElementNameType.labelText:
Expand All @@ -58,6 +63,7 @@ function setFeatureStyle({
style: (elementStyle as SubElementType)[
subElement
] as StyleType,
isInit,
});
});
break;
Expand All @@ -71,6 +77,7 @@ function setFeatureStyle({

interface setElementStyleProps extends ActionPayload {
map: mapboxgl.Map;
isInit: boolean;
}

function setElementStyle({
Expand All @@ -80,7 +87,9 @@ function setElementStyle({
element,
subElement,
style,
isInit,
}: setElementStyleProps): void {
if (!style.isChanged && !isInit) return;
const keys = Object.keys(style) as StyleKeyType[];
keys.forEach((key) => {
mapStyling[feature]({
Expand Down

0 comments on commit 90ca64b

Please sign in to comment.