diff --git a/app/src/UI/Map2/LayerPicker/LpRecordSet/LpRecordSet.tsx b/app/src/UI/Map2/LayerPicker/LpRecordSet/LpRecordSet.tsx index 91c2f7121..37d629455 100644 --- a/app/src/UI/Map2/LayerPicker/LpRecordSet/LpRecordSet.tsx +++ b/app/src/UI/Map2/LayerPicker/LpRecordSet/LpRecordSet.tsx @@ -4,6 +4,8 @@ import './LpRecordSet.css'; import LpRecordSetOption from './LpRecordSetOption'; import UserSettings from 'state/actions/userSettings/UserSettings'; import { UserRecordSet } from 'interfaces/UserRecordSet'; +import filterRecordsetsByNetworkState from 'utils/filterRecordsetsByNetworkState'; +import { MOBILE } from 'state/build-time-config'; type PropTypes = { closePicker: () => void; @@ -17,12 +19,14 @@ const LpRecordSet = ({ closePicker }: PropTypes) => { const handleToggleVisibility = (id: string) => dispatch(UserSettings.RecordSet.toggleVisibility(id)); const handleCycleColour = (id: string) => dispatch(UserSettings.RecordSet.cycleColourById(id)); const handleToggleLabels = (id: string) => dispatch(UserSettings.RecordSet.toggleLabelVisibility(id)); + const connected = useSelector((state) => state.Network.connected); const recordSets = useSelector((state) => state.UserSettings?.recordSets); const defaultRecordSets: UserRecordSet[] = []; const customRecordSets: UserRecordSet[] = []; const dispatch = useDispatch(); - Object.keys(recordSets).forEach((recordSet) => { + const userIsMobileAndOffline = MOBILE && !connected; + filterRecordsetsByNetworkState(recordSets, userIsMobileAndOffline).forEach((recordSet) => { if (DEFAULT_RECORD_TYPES.includes(recordSet)) { defaultRecordSets.push({ ...recordSets[recordSet], id: recordSet }); } else { diff --git a/app/src/UI/Overlay/Records/Record.tsx b/app/src/UI/Overlay/Records/Record.tsx index 916203d27..233fb5f9f 100644 --- a/app/src/UI/Overlay/Records/Record.tsx +++ b/app/src/UI/Overlay/Records/Record.tsx @@ -2,7 +2,7 @@ import { useRef } from 'react'; import './Record.css'; import { Route, useHistory } from 'react-router'; -import { useSelector } from 'react-redux'; +import { useSelector } from 'utils/use_selector'; import { ActivityForm } from './Activity/Form'; import { ActivityPhotos } from './Activity/Photos'; import { OverlayHeader } from '../OverlayHeader'; @@ -19,12 +19,12 @@ export const Activity = (props) => { const history = useHistory(); const id = history.location.pathname.split(':')[1]?.split('/')[0]; - const failCode = useSelector((state: any) => state.ActivityPage?.failCode); - const activity_ID = useSelector((state: any) => state.ActivityPage?.activity?.activity_id); + const failCode = useSelector((state) => state.ActivityPage?.failCode); + const activity_ID = useSelector((state) => state.ActivityPage?.activity?.activity_id); - const loading = useSelector((state: any) => state.ActivityPage?.loading); - const apiDocsWithSelectOptions = useSelector((state: any) => state.UserSettings?.apiDocsWithSelectOptions); - const apiDocsWithViewOptions = useSelector((state: any) => state.UserSettings?.apiDocsWithViewOptions); + const loading = useSelector((state) => state.ActivityPage?.loading); + const apiDocsWithSelectOptions = useSelector((state) => state.UserSettings?.apiDocsWithSelectOptions); + const apiDocsWithViewOptions = useSelector((state) => state.UserSettings?.apiDocsWithViewOptions); return (
Any recordsets that haven't been saved for offline use will not be accessible when you're offline.