From a483ca9837e12e2385d0e2407e52d6c64ae435e2 Mon Sep 17 00:00:00 2001 From: Nicolai Van der Storm Date: Mon, 13 Jun 2022 21:34:51 +0200 Subject: [PATCH] fix(jellyfinimportmodal): fix for importing all jellyfin users --- .../UserList/JellyfinImportModal.tsx | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/components/UserList/JellyfinImportModal.tsx b/src/components/UserList/JellyfinImportModal.tsx index c3cf12a5f..c57e06516 100644 --- a/src/components/UserList/JellyfinImportModal.tsx +++ b/src/components/UserList/JellyfinImportModal.tsx @@ -51,6 +51,18 @@ const JellyfinImportModal: React.FC = ({ revalidateOnMount: true, }); + const { data: existingUsers } = useSWR( + `/api/v1/user?take=${children}` + ); + + data?.forEach((user, pos) => { + if ( + existingUsers?.results.some((data) => data.jellyfinUserId === user.id) + ) { + data?.splice(pos, 1); + } + }); + const importUsers = async () => { setImporting(true); @@ -119,20 +131,6 @@ const JellyfinImportModal: React.FC = ({ } }; - const { data: existingUsers } = useSWR( - `/api/v1/user?take=${children}` - ); - - data?.forEach((user, pos) => { - if ( - existingUsers?.results.some( - (existingUser) => existingUser.jellyfinUserId === user.id - ) - ) { - delete data[pos]; - } - }); - return (