mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -07:00
fix(ui): move sync file I/O out of render loop in AppHeader
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type React from 'react';
|
import type React from 'react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo, useEffect, useState } from 'react';
|
||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import { theme } from '../semantic-colors.js';
|
import { theme } from '../semantic-colors.js';
|
||||||
import {
|
import {
|
||||||
@@ -20,16 +20,17 @@ interface UserIdentityProps {
|
|||||||
|
|
||||||
export const UserIdentity: React.FC<UserIdentityProps> = ({ config }) => {
|
export const UserIdentity: React.FC<UserIdentityProps> = ({ config }) => {
|
||||||
const authType = config.getContentGeneratorConfig()?.authType;
|
const authType = config.getContentGeneratorConfig()?.authType;
|
||||||
|
const [email, setEmail] = useState<string | undefined>();
|
||||||
|
|
||||||
const { email, tierName } = useMemo(() => {
|
useEffect(() => {
|
||||||
if (!authType) {
|
if (authType) {
|
||||||
return { email: undefined, tierName: undefined };
|
const userAccountManager = new UserAccountManager();
|
||||||
|
setEmail(userAccountManager.getCachedGoogleAccount() ?? undefined);
|
||||||
}
|
}
|
||||||
const userAccountManager = new UserAccountManager();
|
}, [authType]);
|
||||||
return {
|
|
||||||
email: userAccountManager.getCachedGoogleAccount(),
|
const tierName = useMemo(() => {
|
||||||
tierName: config.getUserTierName(),
|
return authType ? config.getUserTierName() : undefined;
|
||||||
};
|
|
||||||
}, [config, authType]);
|
}, [config, authType]);
|
||||||
|
|
||||||
if (!authType) {
|
if (!authType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user