Skip to content

Commit 3a10a76

Browse files
authored
Merge pull request #917 from transformerlab/fix/user-teams-lag
Show teams dropdown only when user info is available
2 parents 4567788 + 3c56f82 commit 3a10a76

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

src/renderer/components/Nav/UserWidget.tsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ export default function LoginChip({}: Props) {
4545

4646
const { data: teams } = useAPI('teams', ['list']);
4747

48+
// Don't render anything until email is available
49+
if (!email) {
50+
return null;
51+
}
52+
4853
return (
4954
<Sheet
5055
// onClick={() => {
@@ -127,29 +132,30 @@ export default function LoginChip({}: Props) {
127132
Team Settings
128133
</MenuItem>
129134
<Divider />
130-
{teams?.teams.length > 0 ? (
135+
{user && teams?.teams.length > 0 ? (
131136
// header indicator for teams (non-interactive)
132137
<MenuItem disabled>Select Team:</MenuItem>
133138
) : null}
134-
{teams?.teams.map((t: any) => (
135-
<MenuItem
136-
key={t.id}
137-
onClick={() => {
138-
// try common setter names on authContext, otherwise navigate
139-
authContext.setTeam(t);
140-
}}
141-
sx={{
142-
fontWeight: authContext.team?.id === t.id ? 'bold' : 'normal',
143-
}}
144-
>
145-
<ListItemDecorator>
146-
{authContext.team?.id === t.id ? (
147-
<ArrowRightIcon size={16} strokeWidth={4} />
148-
) : null}
149-
</ListItemDecorator>
150-
{t.name}
151-
</MenuItem>
152-
))}
139+
{user &&
140+
teams?.teams.map((t: any) => (
141+
<MenuItem
142+
key={t.id}
143+
onClick={() => {
144+
// try common setter names on authContext, otherwise navigate
145+
authContext.setTeam(t);
146+
}}
147+
sx={{
148+
fontWeight: authContext.team?.id === t.id ? 'bold' : 'normal',
149+
}}
150+
>
151+
<ListItemDecorator>
152+
{authContext.team?.id === t.id ? (
153+
<ArrowRightIcon size={16} strokeWidth={4} />
154+
) : null}
155+
</ListItemDecorator>
156+
{t.name}
157+
</MenuItem>
158+
))}
153159
<Divider />
154160
<MenuItem
155161
onClick={() => {

0 commit comments

Comments
 (0)