Fetch inactive account usage on expand (#3340)
* Fetch inactive account usage on expand * Keep Claude usage fetch outside state 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:
@@ -643,8 +643,12 @@ function ClaudeSwitcherMenu({
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (accountsExpanded) {
|
||||
// Why: inactive-account usage is needed only for the explicit switcher
|
||||
// expansion, so fetch it on that event instead of one render later.
|
||||
const handleAccountsExpandedToggle = useCallback((): void => {
|
||||
const nextExpanded = !accountsExpanded
|
||||
setAccountsExpanded(nextExpanded)
|
||||
if (nextExpanded) {
|
||||
void fetchInactiveClaudeAccountUsage()
|
||||
}
|
||||
}, [accountsExpanded, fetchInactiveClaudeAccountUsage])
|
||||
@@ -735,7 +739,7 @@ function ClaudeSwitcherMenu({
|
||||
<DropdownMenuItem
|
||||
onSelect={(event) => {
|
||||
event.preventDefault()
|
||||
setAccountsExpanded((prev) => !prev)
|
||||
handleAccountsExpandedToggle()
|
||||
}}
|
||||
>
|
||||
<span className="max-w-[180px] truncate text-[12px] text-foreground">
|
||||
|
||||
Reference in New Issue
Block a user