Created
July 2, 2022 15:59
-
-
Save jasonLaster/2467ba3ccb272fb32436f70755e3f01f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx b/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx | |
index 5ca7d4239..f47130487 100644 | |
--- a/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx | |
+++ b/src/devtools/client/debugger/src/components/Editor/LineNumberTooltip.tsx | |
@@ -27,8 +27,9 @@ function Wrapper({ | |
loading?: boolean; | |
showWarning?: boolean; | |
}) { | |
- const { nags } = hooks.useGetUserInfo(); | |
- const showNag = shouldShowNag(nags, Nag.FIRST_BREAKPOINT_ADD); | |
+ const { user } = hooks.useGetUserInfo(); | |
+ | |
+ const showNag = shouldShowNag(user!.nags, Nag.FIRST_BREAKPOINT_ADD); | |
if (showWarning) { | |
return ( | |
diff --git a/src/devtools/client/debugger/src/components/Editor/ToggleWidgetButton.tsx b/src/devtools/client/debugger/src/components/Editor/ToggleWidgetButton.tsx | |
index 9a42be291..081f6d2df 100644 | |
--- a/src/devtools/client/debugger/src/components/Editor/ToggleWidgetButton.tsx | |
+++ b/src/devtools/client/debugger/src/components/Editor/ToggleWidgetButton.tsx | |
@@ -97,8 +97,8 @@ function QuickActions({ | |
const dispatch = useAppDispatch(); | |
const analysisPoints = useAppSelector(getPointsForHoveredLineNumber); | |
const executionPoint = useAppSelector(getExecutionPoint); | |
- const { nags } = hooks.useGetUserInfo(); | |
- const showNag = shouldShowNag(nags, Nag.FIRST_BREAKPOINT_ADD); | |
+ const { user } = hooks.useGetUserInfo(); | |
+ const showNag = shouldShowNag(user!.nags, Nag.FIRST_BREAKPOINT_ADD); | |
const { height } = targetNode.getBoundingClientRect(); | |
const { value: enableLargeText } = useFeature("enableLargeText"); | |
const { value: hitCounts } = useFeature("hitCounts"); | |
diff --git a/src/ui/components/Library/Library.tsx b/src/ui/components/Library/Library.tsx | |
index 825ed5582..043903fd4 100644 | |
--- a/src/ui/components/Library/Library.tsx | |
+++ b/src/ui/components/Library/Library.tsx | |
@@ -51,13 +51,13 @@ function useGetIsValidTeamId(teamId: string | null) { | |
export default function LibraryLoader() { | |
const { userSettings, loading: userSettingsLoading } = hooks.useGetUserSettings(); | |
- const { loading: userInfoLoading, ...userInfo } = hooks.useGetUserInfo(); | |
+ const { loading: userInfoLoading, user } = hooks.useGetUserInfo(); | |
if (userSettingsLoading || userInfoLoading) { | |
return <LoadingScreen fallbackMessage="Reloading team details..." />; | |
} | |
- return <Library userSettings={userSettings} userInfo={userInfo} />; | |
+ return <Library userSettings={userSettings} userInfo={user} />; | |
} | |
function Library({ | |
diff --git a/src/ui/hooks/users.ts b/src/ui/hooks/users.ts | |
index 0f692bad3..7cc64c624 100644 | |
--- a/src/ui/hooks/users.ts | |
+++ b/src/ui/hooks/users.ts | |
@@ -112,11 +112,16 @@ export async function getUserInfo(): Promise<UserInfo | undefined> { | |
}; | |
} | |
-export function useGetUserInfo(): UserInfo & { loading: boolean } { | |
+export function useGetUserInfo(): { user?: UserInfo; error?: string; loading?: true } { | |
const { data, loading, error } = useQuery<GetUser>(GET_USER_INFO); | |
if (error) { | |
console.error("Apollo error while fetching user:", error); | |
+ return { error: error.message }; | |
+ } | |
+ | |
+ if (loading) { | |
+ return { loading }; | |
} | |
const id: string = data?.viewer?.user.id!; | |
@@ -134,17 +139,18 @@ export function useGetUserInfo(): UserInfo & { loading: boolean } { | |
}; | |
return { | |
- loading, | |
- id, | |
- email, | |
- picture, | |
- name, | |
- internal, | |
- nags, | |
- acceptedTOSVersion, | |
- unsubscribedEmailTypes, | |
- motd, | |
- features, | |
+ user: { | |
+ id, | |
+ email, | |
+ picture, | |
+ name, | |
+ internal, | |
+ nags, | |
+ acceptedTOSVersion, | |
+ unsubscribedEmailTypes, | |
+ motd, | |
+ features, | |
+ }, | |
}; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment