aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/layout/CurrentIdentity.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'webui/src/layout/CurrentIdentity.tsx')
-rw-r--r--webui/src/layout/CurrentIdentity.tsx30
1 files changed, 19 insertions, 11 deletions
diff --git a/webui/src/layout/CurrentIdentity.tsx b/webui/src/layout/CurrentIdentity.tsx
index 21f489ef..55060179 100644
--- a/webui/src/layout/CurrentIdentity.tsx
+++ b/webui/src/layout/CurrentIdentity.tsx
@@ -3,7 +3,7 @@ import React from 'react';
import Avatar from '@material-ui/core/Avatar';
import { makeStyles } from '@material-ui/core/styles';
-import { useCurrentIdentityQuery } from './CurrentIdentity.generated';
+import CurrentIdentityContext from './CurrentIdentityContext';
const useStyles = makeStyles(theme => ({
displayName: {
@@ -13,18 +13,26 @@ const useStyles = makeStyles(theme => ({
const CurrentIdentity = () => {
const classes = useStyles();
- const { loading, error, data } = useCurrentIdentityQuery();
- if (error || loading || !data?.repository?.userIdentity) return null;
-
- const user = data.repository.userIdentity;
return (
- <>
- <Avatar src={user.avatarUrl ? user.avatarUrl : undefined}>
- {user.displayName.charAt(0).toUpperCase()}
- </Avatar>
- <div className={classes.displayName}>{user.displayName}</div>
- </>
+ <CurrentIdentityContext.Consumer>
+ {context => {
+ if (!context) return null;
+ const { loading, error, data } = context as any;
+
+ if (error || loading || !data?.repository?.userIdentity) return null;
+
+ const user = data.repository.userIdentity;
+ return (
+ <>
+ <Avatar src={user.avatarUrl ? user.avatarUrl : undefined}>
+ {user.displayName.charAt(0).toUpperCase()}
+ </Avatar>
+ <div className={classes.displayName}>{user.displayName}</div>
+ </>
+ );
+ }}
+ </CurrentIdentityContext.Consumer>
);
};