Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3249540
D5587.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5587.diff
View Options
diff --git a/native/profile/build-info.react.js b/native/profile/build-info.react.js
--- a/native/profile/build-info.react.js
+++ b/native/profile/build-info.react.js
@@ -2,23 +2,19 @@
import * as React from 'react';
import { View, Text, ScrollView } from 'react-native';
-import { useSelector } from 'react-redux';
-
-import { isStaff } from 'lib/shared/user-utils';
import { persistConfig, codeVersion } from '../redux/persist';
import { StaffContext } from '../staff/staff-context';
import { useStyles } from '../themes/colors';
-import { isStaffRelease, useStaffCanSee } from '../utils/staff-utils';
+import {
+ isStaffRelease,
+ useIsCurrentUserStaff,
+ useStaffCanSee,
+} from '../utils/staff-utils';
// eslint-disable-next-line no-unused-vars
function BuildInfo(props: { ... }): React.Node {
- const isCurrentUserStaff = useSelector(
- state =>
- state.currentUserInfo &&
- state.currentUserInfo.id &&
- isStaff(state.currentUserInfo.id),
- );
+ const isCurrentUserStaff = useIsCurrentUserStaff();
const { staffUserHasBeenLoggedIn } = React.useContext(StaffContext);
const styles = useStyles(unboundStyles);
const staffCanSee = useStaffCanSee();
diff --git a/native/staff/staff-context.provider.react.js b/native/staff/staff-context.provider.react.js
--- a/native/staff/staff-context.provider.react.js
+++ b/native/staff/staff-context.provider.react.js
@@ -1,10 +1,8 @@
// @flow
import * as React from 'react';
-import { useSelector } from 'react-redux';
-
-import { isStaff } from 'lib/shared/user-utils';
+import { useIsCurrentUserStaff } from '../utils/staff-utils';
import { StaffContext, type StaffContextType } from './staff-context';
type Props = {
@@ -16,12 +14,7 @@
setStaffUserHasBeenLoggedIn,
] = React.useState(false);
- const isCurrentUserStaff = useSelector(
- state =>
- state.currentUserInfo &&
- state.currentUserInfo.id &&
- isStaff(state.currentUserInfo.id),
- );
+ const isCurrentUserStaff = useIsCurrentUserStaff();
React.useEffect(() => {
if (isCurrentUserStaff) {
diff --git a/native/utils/staff-utils.js b/native/utils/staff-utils.js
--- a/native/utils/staff-utils.js
+++ b/native/utils/staff-utils.js
@@ -6,14 +6,19 @@
const isStaffRelease = false;
-function useStaffCanSee(): boolean {
+function useIsCurrentUserStaff(): boolean {
const isCurrentUserStaff = useSelector(
state =>
state.currentUserInfo &&
state.currentUserInfo.id &&
isStaff(state.currentUserInfo.id),
);
+ return isCurrentUserStaff;
+}
+
+function useStaffCanSee(): boolean {
+ const isCurrentUserStaff = useIsCurrentUserStaff();
return __DEV__ || isStaffRelease || isCurrentUserStaff;
}
-export { isStaffRelease, useStaffCanSee };
+export { isStaffRelease, useIsCurrentUserStaff, useStaffCanSee };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 3:54 PM (17 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2498159
Default Alt Text
D5587.diff (2 KB)
Attached To
Mode
D5587: [native] Pull `useIsCurrentUserStaff()` out of `useStaffCanSee()`
Attached
Detach File
Event Timeline
Log In to Comment