Skip to content

Commit

Permalink
Prune code in Records.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
LocalNewsTV authored and plasticviking committed Nov 28, 2024
1 parent 83a9c5f commit 18c11a0
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions app/src/UI/Overlay/Records/Records.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { MouseEvent, useEffect, useState } from 'react';

import { Button } from '@mui/material';
import './Records.css';
import { OverlayHeader } from '../OverlayHeader';
import Spinner from 'UI/Spinner/Spinner';
import { useHistory } from 'react-router-dom';
import { useDispatch, useSelector } from 'utils/use_selector';
import UserSettings from 'state/actions/userSettings/UserSettings';
Expand All @@ -16,15 +14,9 @@ import filterRecordsetsByNetworkState from 'utils/filterRecordsetsByNetworkState

export const Records = () => {
const DEFAULT_RECORD_TYPES = ['All InvasivesBC Activities', 'All IAPP Records', 'My Drafts'];
const activitiesGeoJSONState = useSelector((state) => state.Map?.activitiesGeoJSONDict);
const isIAPPGeoJSONLoaded = useSelector((state) => state.Map?.IAPPGeoJSONDict !== undefined);
const mapLayers = useSelector((state) => state.Map.layers);
const MapMode = useSelector((state) => state.Map.MapMode);
const recordSets = useSelector((state) => state.UserSettings?.recordSets);
const connected = useSelector((state) => state.Network.connected);
const [highlightedSet, setHighlightedSet] = useState<string | null>();
const [isActivitiesGeoJSONLoaded, setIsActivitiesGeoJSONLoaded] = useState(false);
const [loadMap, setLoadMap] = useState({});

const history = useHistory();
const dispatch = useDispatch();
Expand All @@ -37,23 +29,6 @@ export const Records = () => {
dispatch(UserSettings.RecordSet.syncCacheStatusWithCacheService());
}, []);

useEffect(() => {
setIsActivitiesGeoJSONLoaded(activitiesGeoJSONState.hasOwnProperty('s3'));
}, [activitiesGeoJSONState]);

useEffect(() => {
const rv = {};
mapLayers.forEach((layer) => {
const geojson = layer?.type === RecordSetType.Activity ? isActivitiesGeoJSONLoaded : isIAPPGeoJSONLoaded;
if (MapMode !== 'VECTOR_ENDPOINT') {
rv[layer?.recordSetID] = !layer?.loading && geojson;
} else {
rv[layer?.recordSetID] = !layer?.loading;
}
});
setLoadMap(rv);
}, [JSON.stringify(mapLayers), isActivitiesGeoJSONLoaded, isIAPPGeoJSONLoaded, MapMode]);

//Record set handlers:
const handleToggleLabel = (set: string, e: MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
Expand Down Expand Up @@ -116,13 +91,7 @@ export const Records = () => {
isDefaultRecordset={DEFAULT_RECORD_TYPES.includes(recordSets[set]?.recordSetName)}
handleNameChange={handleNameChange}
recordsetKey={set}
>
{!loadMap?.[set] && (
<div>
<Spinner />
</div>
)}
</RecordSetDetails>
></RecordSetDetails>

<RecordSetControl
isDefaultRecordset={DEFAULT_RECORD_TYPES.includes(recordSets[set]?.recordSetName)}
Expand Down

0 comments on commit 18c11a0

Please sign in to comment.