Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3366258
D5513.id18005.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
D5513.id18005.diff
View Options
diff --git a/native/root.react.js b/native/root.react.js
--- a/native/root.react.js
+++ b/native/root.react.js
@@ -43,6 +43,7 @@
import { useSelector } from './redux/redux-utils';
import { RootContext } from './root-context';
import Socket from './socket.react';
+import { StaffContextProvider } from './staff/staff-context.provider.react';
import { DarkTheme, LightTheme } from './themes/navigation';
import ThemeHandler from './themes/theme-handler.react';
import './themes/fonts';
@@ -241,33 +242,35 @@
}
return (
<View style={styles.app}>
- <CoreDataProvider>
- <NavContext.Provider value={navContext}>
- <RootContext.Provider value={rootContext}>
- <InputStateContainer>
- <SafeAreaProvider initialMetrics={initialWindowMetrics}>
- <ChatContextProvider>
- <SQLiteContextProvider>
- <ConnectedStatusBar />
- <ReduxPersistGate persistor={getPersistor()}>
- {gated}
- </ReduxPersistGate>
- <PersistedStateGate>
- <Socket
- detectUnsupervisedBackgroundRef={
- detectUnsupervisedBackgroundRef
- }
- />
- </PersistedStateGate>
- {navigation}
- <NavigationHandler />
- </SQLiteContextProvider>
- </ChatContextProvider>
- </SafeAreaProvider>
- </InputStateContainer>
- </RootContext.Provider>
- </NavContext.Provider>
- </CoreDataProvider>
+ <StaffContextProvider>
+ <CoreDataProvider>
+ <NavContext.Provider value={navContext}>
+ <RootContext.Provider value={rootContext}>
+ <InputStateContainer>
+ <SafeAreaProvider initialMetrics={initialWindowMetrics}>
+ <ChatContextProvider>
+ <SQLiteContextProvider>
+ <ConnectedStatusBar />
+ <ReduxPersistGate persistor={getPersistor()}>
+ {gated}
+ </ReduxPersistGate>
+ <PersistedStateGate>
+ <Socket
+ detectUnsupervisedBackgroundRef={
+ detectUnsupervisedBackgroundRef
+ }
+ />
+ </PersistedStateGate>
+ {navigation}
+ <NavigationHandler />
+ </SQLiteContextProvider>
+ </ChatContextProvider>
+ </SafeAreaProvider>
+ </InputStateContainer>
+ </RootContext.Provider>
+ </NavContext.Provider>
+ </CoreDataProvider>
+ </StaffContextProvider>
</View>
);
}
diff --git a/native/staff/staff-context.provider.react.js b/native/staff/staff-context.provider.react.js
new file mode 100644
--- /dev/null
+++ b/native/staff/staff-context.provider.react.js
@@ -0,0 +1,44 @@
+// @flow
+
+import * as React from 'react';
+import { useSelector } from 'react-redux';
+
+import { isStaff } from 'lib/shared/user-utils';
+
+import { StaffContext, type StaffContextType } from './staff-context';
+
+type Props = {
+ +children: React.Node,
+};
+function StaffContextProvider(props: Props): React.Node {
+ const [
+ staffUserHasBeenLoggedIn,
+ setStaffUserHasBeenLoggedIn,
+ ] = React.useState(false);
+
+ const isCurrentUserStaff = useSelector(
+ state =>
+ state.currentUserInfo &&
+ state.currentUserInfo.id &&
+ isStaff(state.currentUserInfo.id),
+ );
+
+ React.useEffect(() => {
+ if (isCurrentUserStaff) {
+ setStaffUserHasBeenLoggedIn(true);
+ }
+ }, [isCurrentUserStaff]);
+
+ const staffContextValue: StaffContextType = React.useMemo(
+ () => ({ staffUserHasBeenLoggedIn }),
+ [staffUserHasBeenLoggedIn],
+ );
+
+ return (
+ <StaffContext.Provider value={staffContextValue}>
+ {props.children}
+ </StaffContext.Provider>
+ );
+}
+
+export { StaffContextProvider };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 10:25 AM (18 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2582652
Default Alt Text
D5513.id18005.diff (4 KB)
Attached To
Mode
D5513: [native] Introduce `StaffContextProvider`
Attached
Detach File
Event Timeline
Log In to Comment