Page MenuHomePhabricator

D5587.id18293.diff
No OneTemporary

D5587.id18293.diff

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

Mime Type
text/plain
Expires
Sat, Nov 16, 5:56 PM (20 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2498159
Default Alt Text
D5587.id18293.diff (2 KB)

Event Timeline