Skip to content

Commit

Permalink
fix: resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TreffN committed Aug 5, 2024
1 parent 31528cc commit c068bc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
13 changes: 2 additions & 11 deletions src/components/ToolMenu/LayerTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {

import useAppSelector from '../../../hooks/useAppSelector';
import useSHOGunAPIClient from '../../../hooks/useSHOGunAPIClient';
import { UploadTools } from '../../../store/layerTree';

import WmsTimeSlider from '../../WmsTimeSlider';

Expand All @@ -59,12 +58,6 @@ export type LayerTileLoadCounter = {
};
};

export type LayerTreeConfig = {
enabled?: boolean;
activeUploadTools?: UploadTools[];
showLegends?: boolean;
};

export const LayerTree: React.FC<LayerTreeProps> = ({
...restProps
}): JSX.Element => {
Expand All @@ -74,13 +67,11 @@ export const LayerTree: React.FC<LayerTreeProps> = ({
t
} = useTranslation();

const showLegendsState = useAppSelector(state => state.layerTree.showLegends);
// check if showLegends is defined
const showLegends: boolean = showLegendsState ? showLegendsState : false;
const showLegendsState: boolean = useAppSelector(state => state.layerTree.showLegends) ?? false;

const initialLayersUid = map?.getAllLayers().map(l => getUid(l));

const [visibleLegendsIds, setVisibleLegendsIds] = useState<string[]> (showLegends? initialLayersUid ?? [] : []);
const [visibleLegendsIds, setVisibleLegendsIds] = useState<string[]> (showLegendsState ? initialLayersUid ?? [] : []);
const [layerTileLoadCounter, setLayerTileLoadCounter] = useState<LayerTileLoadCounter>({});

const registerTileLoadHandler = useCallback(() => {
Expand Down
6 changes: 5 additions & 1 deletion src/store/layerTree/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import {
PayloadAction
} from '@reduxjs/toolkit';

import { LayerTreeConfig } from '../../components/ToolMenu/LayerTree';
export type LayerTreeConfig = {
enabled?: boolean;
activeUploadTools?: UploadTools[];
showLegends?: boolean;
};

// eslint-disable-next-line no-shadow
export enum UploadTools {
Expand Down

0 comments on commit c068bc2

Please sign in to comment.