Fetch Codex account usage on expand (#3435)
* Fetch Codex account usage on expand * Avoid side effects in Codex account toggle updater Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com> Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -1211,8 +1211,12 @@ function CodexSwitcherMenu({
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (accountsExpanded) {
|
||||
const handleAccountsExpandedToggle = useCallback((): void => {
|
||||
const nextExpanded = !accountsExpanded
|
||||
setAccountsExpanded(nextExpanded)
|
||||
if (nextExpanded) {
|
||||
// Why: inactive-account usage is needed only for the explicit switcher
|
||||
// expansion, so fetch it on that event instead of one render later.
|
||||
void fetchInactiveCodexAccountUsage()
|
||||
}
|
||||
}, [accountsExpanded, fetchInactiveCodexAccountUsage])
|
||||
@@ -1257,7 +1261,7 @@ function CodexSwitcherMenu({
|
||||
<DropdownMenuItem
|
||||
onSelect={(event) => {
|
||||
event.preventDefault()
|
||||
setAccountsExpanded((prev) => !prev)
|
||||
handleAccountsExpandedToggle()
|
||||
}}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-0.5 py-0.5 text-[12px]">
|
||||
|
||||
Reference in New Issue
Block a user