Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3397397
D5581.id18260.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D5581.id18260.diff
View Options
diff --git a/native/data/sensitive-data-handler.react.js b/native/data/sensitive-data-handler.react.js
deleted file mode 100644
--- a/native/data/sensitive-data-handler.react.js
+++ /dev/null
@@ -1,43 +0,0 @@
-// @flow
-
-import * as React from 'react';
-import ExitApp from 'react-native-exit-app';
-
-import { commCoreModule } from '../native-modules';
-import { useSelector } from '../redux/redux-utils';
-
-function SensitiveDataHandler(): null {
- const currentLoggedInUserID: ?string = useSelector(state =>
- state.currentUserInfo?.anonymous ? undefined : state.currentUserInfo?.id,
- );
- React.useEffect(() => {
- (async () => {
- try {
- const databaseCurrentUserInfoID = await commCoreModule.getCurrentUserID();
- if (
- databaseCurrentUserInfoID &&
- databaseCurrentUserInfoID !== currentLoggedInUserID
- ) {
- await commCoreModule.clearSensitiveData();
- }
- if (currentLoggedInUserID) {
- await commCoreModule.setCurrentUserID(currentLoggedInUserID);
- }
- const databaseDeviceID = await commCoreModule.getDeviceID();
- if (!databaseDeviceID) {
- await commCoreModule.setDeviceID('MOBILE');
- }
- } catch (e) {
- if (__DEV__) {
- throw e;
- } else {
- console.log(e);
- ExitApp.exitApp();
- }
- }
- })();
- }, [currentLoggedInUserID]);
- return null;
-}
-
-export { SensitiveDataHandler };
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
@@ -33,9 +33,42 @@
const urlPrefix = useSelector(state => state.urlPrefix);
const staffCanSee = useStaffCanSee();
const loggedIn = useSelector(isLoggedIn);
+ const currentLoggedInUserID = useSelector(state =>
+ state.currentUserInfo?.anonymous ? undefined : state.currentUserInfo?.id,
+ );
+
+ const handleSensitiveData = React.useCallback(async () => {
+ try {
+ const databaseCurrentUserInfoID = await commCoreModule.getCurrentUserID();
+ if (
+ databaseCurrentUserInfoID &&
+ databaseCurrentUserInfoID !== currentLoggedInUserID
+ ) {
+ await commCoreModule.clearSensitiveData();
+ }
+ if (currentLoggedInUserID) {
+ await commCoreModule.setCurrentUserID(currentLoggedInUserID);
+ }
+ const databaseDeviceID = await commCoreModule.getDeviceID();
+ if (!databaseDeviceID) {
+ await commCoreModule.setDeviceID('MOBILE');
+ }
+ } catch (e) {
+ if (__DEV__) {
+ throw e;
+ } else {
+ console.log(e);
+ ExitApp.exitApp();
+ }
+ }
+ }, [currentLoggedInUserID]);
React.useEffect(() => {
- if (storeLoaded || !rehydrateConcluded) {
+ if (!rehydrateConcluded) {
+ return;
+ }
+ const sensitiveDataHandled = handleSensitiveData();
+ if (storeLoaded) {
return;
}
if (!loggedIn) {
@@ -43,6 +76,7 @@
return;
}
(async () => {
+ await sensitiveDataHandled;
try {
const [threads, messages] = await Promise.all([
commCoreModule.getAllThreads(),
@@ -92,6 +126,7 @@
}
})();
}, [
+ handleSensitiveData,
loggedIn,
cookie,
dispatch,
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -23,7 +23,6 @@
import PersistedStateGate from './components/persisted-state-gate';
import ConnectedStatusBar from './connected-status-bar.react';
import CoreDataProvider from './data/core-data-provider.react';
-import { SensitiveDataHandler } from './data/sensitive-data-handler.react';
import { SQLiteContextProvider } from './data/sqlite-context-provider';
import ErrorBoundary from './error-boundary.react';
import InputStateContainer from './input/input-state-container.react';
@@ -225,7 +224,6 @@
<ConnectivityUpdater />
<ThemeHandler />
<OrientationHandler />
- <SensitiveDataHandler />
</>
);
let navigation;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 5:31 PM (22 h, 40 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2608359
Default Alt Text
D5581.id18260.diff (4 KB)
Attached To
Mode
D5581: Merge SensitiveDataHandler functionality into SQLiteContextProvider
Attached
Detach File
Event Timeline
Log In to Comment