diff --git a/app/src/UI/Overlay/Records/Records.tsx b/app/src/UI/Overlay/Records/Records.tsx index 7faac6971..ad8050d6a 100644 --- a/app/src/UI/Overlay/Records/Records.tsx +++ b/app/src/UI/Overlay/Records/Records.tsx @@ -5,12 +5,13 @@ import { OverlayHeader } from '../OverlayHeader'; import { useHistory } from 'react-router-dom'; import { useDispatch, useSelector } from 'utils/use_selector'; import UserSettings from 'state/actions/userSettings/UserSettings'; -import { RecordSetType } from 'interfaces/UserRecordSet'; +import { RecordSetType, UserRecordCacheStatus } from 'interfaces/UserRecordSet'; import Prompt from 'state/actions/prompts/Prompt'; import RecordSetDetails from './RecordSetDetails'; import RecordSetControl from './RecordSetControl'; import { MOBILE } from 'state/build-time-config'; import filterRecordsetsByNetworkState from 'utils/filterRecordsetsByNetworkState'; +import RecordCache from 'state/actions/cache/RecordCache'; export const Records = () => { const DEFAULT_RECORD_TYPES = ['All InvasivesBC Activities', 'All IAPP Records', 'My Drafts']; @@ -49,7 +50,10 @@ export const Records = () => { e.stopPropagation(); const callback = (userConfirmation: boolean) => { if (userConfirmation) { - dispatch(UserSettings.RecordSet.remove(set)); + if (recordSets[set]?.cacheMetadata?.status === UserRecordCacheStatus.CACHED) { + dispatch(RecordCache.deleteCache({ setId: set })); + } + setTimeout(() => dispatch(UserSettings.RecordSet.remove(set)), 250); } }; dispatch(