1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix error on unmount in syncplay menu

This commit is contained in:
Bill Thornton 2023-09-20 12:38:43 -04:00
parent dbd068b3e1
commit 55a2ca3590

View file

@ -56,9 +56,12 @@ const SyncPlayMenu: FC<SyncPlayMenuProps> = ({
}, []); }, []);
useEffect(() => { useEffect(() => {
let isMounted = true;
const fetchGroups = async () => { const fetchGroups = async () => {
if (api) { if (api) {
setGroups((await getSyncPlayApi(api).syncPlayGetGroups()).data); const response = await getSyncPlayApi(api).syncPlayGetGroups();
if (isMounted) setGroups(response.data);
} }
}; };
@ -66,6 +69,10 @@ const SyncPlayMenu: FC<SyncPlayMenuProps> = ({
.catch(err => { .catch(err => {
console.error('[SyncPlayMenu] unable to fetch SyncPlay groups', err); console.error('[SyncPlayMenu] unable to fetch SyncPlay groups', err);
}); });
return () => {
isMounted = false;
};
}, [ api ]); }, [ api ]);
const onGroupAddClick = useCallback(() => { const onGroupAddClick = useCallback(() => {