Skip to content

Commit

Permalink
Trigger cache delete on Recordset deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
LocalNewsTV committed Jan 2, 2025
1 parent fe0de66 commit a2a2750
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/UI/Overlay/Records/Records.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit a2a2750

Please sign in to comment.