From 61dcd8e487d7886773ccb12501623c17838476e5 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Sun, 11 Aug 2024 19:25:17 +0200 Subject: [PATCH] fix: update the filter removing existing users from Jellyfin import modal (#924) Currently import button sometimes shows already imported users and this would break it if an admin tries to import an already imported user. --- .../UserList/JellyfinImportModal.tsx | 115 +++++++++--------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/src/components/UserList/JellyfinImportModal.tsx b/src/components/UserList/JellyfinImportModal.tsx index ed549ac5..64ca1861 100644 --- a/src/components/UserList/JellyfinImportModal.tsx +++ b/src/components/UserList/JellyfinImportModal.tsx @@ -56,14 +56,6 @@ const JellyfinImportModal: React.FC = ({ `/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); @@ -209,64 +201,71 @@ const JellyfinImportModal: React.FC = ({ - {data?.map((user) => ( - - - toggleUser(user.id)} - onKeyDown={(e) => { - if (e.key === 'Enter' || e.key === 'Space') { - toggleUser(user.id); - } - }} - className="relative inline-flex h-5 w-10 flex-shrink-0 cursor-pointer items-center justify-center pt-2 focus:outline-none" - > + {data + ?.filter( + (user) => + !existingUsers?.results.some( + (u) => u.jellyfinUserId === user.id + ) + ) + .map((user) => ( + + - - - - -
- -
-
- {user.username} -
- {/* {user.username && + role="checkbox" + tabIndex={0} + aria-checked={isSelectedUser(user.id)} + onClick={() => toggleUser(user.id)} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === 'Space') { + toggleUser(user.id); + } + }} + className="relative inline-flex h-5 w-10 flex-shrink-0 cursor-pointer items-center justify-center pt-2 focus:outline-none" + > + + + + + +
+ +
+
+ {user.username} +
+ {/* {user.username && user.username.toLowerCase() !== user.email && (
{user.email}
)} */} +
-
- - - ))} + + + ))}