-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactive legend: Re-calculate layer data when layer is off by default. #154
Conversation
export function getIntLegendLayerData(fLayer: __esri.FeatureLayer, data): IIntLegendLayerData { | ||
return data?.[fLayer?.id]; | ||
export function getIntLegendLayerData(fLayer: __esri.FeatureLayer): IIntLegendLayerData { | ||
const data = interactiveLegendState?.data?.[fLayer?.id]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be returned instead of creating a new variable and not doing anything with it. Also, the return type for this would have better checking if it was IIntLegendLayerData | undefined
since that's what's actually being returned due to the optional chaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Keeping the return type the same for now, changing it will affect other functions. Will address in the future when we're done patching.
export function updateStore(data: IInteractiveLegendData, layerData?: { intLegendLayerData: IIntLegendLayerData; layerId: string }): void { | ||
const layerId = layerData?.layerId; | ||
export function updateStore(layerData: { intLegendLayerData: IIntLegendLayerData; layerId: string }): void { | ||
const layerId = layerData?.layerId as string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could wrap all the lines in this function in an if statement if(layerData != null)
, then you wouldn't need the optional chaining. If layerId
is undefined or null you wouldn't want to run store.set(…)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done
No description provided.