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, @@ -45,6 +47,12 @@ databaseCurrentUserInfoID !== currentLoggedInUserID ) { await commCoreModule.clearSensitiveData(); + if (staffCanSee || staffUserHasBeenLoggedIn) { + Alert.alert( + 'SQLite database deleted', + 'SQLite database deletion was triggered by change in logged-in user credentials', + ); + } } if (currentLoggedInUserID) { await commCoreModule.setCurrentUserID(currentLoggedInUserID); @@ -61,7 +69,7 @@ ExitApp.exitApp(); } } - }, [currentLoggedInUserID]); + }, [currentLoggedInUserID, staffCanSee, staffUserHasBeenLoggedIn]); React.useEffect(() => { if (!rehydrateConcluded) {