diff --git a/native/data/sqlite-context-provider.js b/native/data/sqlite-context-provider.js --- a/native/data/sqlite-context-provider.js +++ b/native/data/sqlite-context-provider.js @@ -15,6 +15,7 @@ import { commCoreModule } from '../native-modules'; import { useSelector } from '../redux/redux-utils'; +import { StaffContext } from '../staff/staff-context'; import { useStaffCanSee } from '../utils/staff-utils'; import { SQLiteContext } from './sqlite-context'; @@ -32,6 +33,7 @@ const cookie = useSelector(state => state.cookie); const urlPrefix = useSelector(state => state.urlPrefix); const staffCanSee = useStaffCanSee(); + const { staffUserHasBeenLoggedIn } = React.useContext(StaffContext); const loggedIn = useSelector(isLoggedIn); const currentLoggedInUserID = useSelector(state => state.currentUserInfo?.anonymous ? undefined : state.currentUserInfo?.id, @@ -44,7 +46,16 @@ databaseCurrentUserInfoID && databaseCurrentUserInfoID !== currentLoggedInUserID ) { + if (staffCanSee || staffUserHasBeenLoggedIn) { + Alert.alert('Starting SQLite database deletion process'); + } await commCoreModule.clearSensitiveData(); + if (staffCanSee || staffUserHasBeenLoggedIn) { + Alert.alert( + 'SQLite database successfully deleted', + 'SQLite database deletion was triggered by change in logged-in user credentials', + ); + } } if (currentLoggedInUserID) { await commCoreModule.setCurrentUserID(currentLoggedInUserID); @@ -61,7 +72,7 @@ ExitApp.exitApp(); } } - }, [currentLoggedInUserID]); + }, [currentLoggedInUserID, staffCanSee, staffUserHasBeenLoggedIn]); React.useEffect(() => { if (!rehydrateConcluded) {