mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(ui): ignore stale available-teams fetch on unmount or token change
This commit is contained in:
parent
fe57eedb5c
commit
484cc12ab6
1 changed files with 12 additions and 2 deletions
|
|
@ -16,6 +16,8 @@ const AvailableTeamsPanel: React.FC<AvailableTeamsProps> = ({ accessToken, userI
|
|||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
let ignore = false;
|
||||
|
||||
const fetchAvailableTeams = async () => {
|
||||
if (!accessToken || !userID) {
|
||||
setIsLoading(false);
|
||||
|
|
@ -24,15 +26,23 @@ const AvailableTeamsPanel: React.FC<AvailableTeamsProps> = ({ accessToken, userI
|
|||
|
||||
try {
|
||||
const response = await availableTeamListCall(accessToken);
|
||||
setAvailableTeams(response);
|
||||
if (!ignore) {
|
||||
setAvailableTeams(response);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error fetching available teams:", error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
if (!ignore) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchAvailableTeams();
|
||||
|
||||
return () => {
|
||||
ignore = true;
|
||||
};
|
||||
}, [accessToken, userID]);
|
||||
|
||||
const handleJoinTeam = async (teamId: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue