()
| 46 | } |
| 47 | |
| 48 | function SQLiteDataHandler(): React.Node { |
| 49 | const initialStateLoaded = useSelector(state => state.initialStateLoaded); |
| 50 | |
| 51 | const dispatch = useDispatch(); |
| 52 | |
| 53 | const rehydrateConcluded = useSelector( |
| 54 | state => !!(state._persist && state._persist.rehydrated), |
| 55 | ); |
| 56 | const staffCanSee = useStaffCanSee(); |
| 57 | const loggedIn = useSelector(isLoggedIn); |
| 58 | const currentLoggedInUserID = useSelector(state => |
| 59 | state.currentUserInfo?.anonymous ? undefined : state.currentUserInfo?.id, |
| 60 | ); |
| 61 | const mediaCacheContext = React.useContext(MediaCacheContext); |
| 62 | |
| 63 | const showCorruptionAlert = React.useCallback(() => { |
| 64 | const { showAlert } = getConfig(); |
| 65 | showAlert( |
| 66 | 'Corrupted data', |
| 67 | 'Comm failed to load your local data. Please log in again.', |
| 68 | ); |
| 69 | }, []); |
| 70 | |
| 71 | const callClearSensitiveData = React.useCallback( |
| 72 | async (triggeredBy: string) => { |
| 73 | await clearSensitiveData(); |
| 74 | const { showAlert, isStaffRelease } = getConfig(); |
| 75 | if (isStaffRelease) { |
| 76 | showAlert('SQLite database deletion', `triggered by ${triggeredBy}`); |
| 77 | } |
| 78 | console.log(`SQLite database deletion was triggered by ${triggeredBy}`); |
| 79 | }, |
| 80 | [], |
| 81 | ); |
| 82 | |
| 83 | const handleSensitiveData = React.useCallback(async () => { |
| 84 | try { |
| 85 | let sqliteStampedUserID, |
| 86 | errorGettingStampedUserID = false; |
| 87 | try { |
| 88 | sqliteStampedUserID = await commCoreModule.getSQLiteStampedUserID(); |
| 89 | } catch (error) { |
| 90 | errorGettingStampedUserID = true; |
| 91 | console.log( |
| 92 | `Error getting SQLite stamped user ID: ${ |
| 93 | getMessageForException(error) ?? 'unknown' |
| 94 | }`, |
| 95 | ); |
| 96 | } |
| 97 | if ( |
| 98 | errorGettingStampedUserID || |
| 99 | shouldClearData(sqliteStampedUserID, currentLoggedInUserID) |
| 100 | ) { |
| 101 | await callClearSensitiveData('change in logged-in user credentials'); |
| 102 | } |
| 103 | if ( |
| 104 | currentLoggedInUserID && |
| 105 | currentLoggedInUserID !== sqliteStampedUserID |
nothing calls this directly
no test coverage detected