Skip to content

Commit

Permalink
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/components/UserList/JellyfinImportModal.tsx
Original file line number Diff line number Diff line change
@@ -51,6 +51,18 @@ const JellyfinImportModal: React.FC<JellyfinImportProps> = ({
revalidateOnMount: true,
});

const { data: existingUsers } = useSWR<UserResultsResponse>(
`/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<JellyfinImportProps> = ({
}
};

const { data: existingUsers } = useSWR<UserResultsResponse>(
`/api/v1/user?take=${children}`
);

data?.forEach((user, pos) => {
if (
existingUsers?.results.some(
(existingUser) => existingUser.jellyfinUserId === user.id
)
) {
delete data[pos];
}
});

return (
<Modal
loading={!data && !error}

0 comments on commit a483ca9

Please sign in to comment.