Skip to content
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

[INV-N/A] Prune code in Records.tsx #3723

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading