diff --git a/packages/backend/src/server/api/endpoints/users/lists/delete.ts b/packages/backend/src/server/api/endpoints/users/lists/delete.ts index 384b7d7132..5a7613c98a 100644 --- a/packages/backend/src/server/api/endpoints/users/lists/delete.ts +++ b/packages/backend/src/server/api/endpoints/users/lists/delete.ts @@ -30,18 +30,14 @@ export const paramDef = { // eslint-disable-next-line import/no-default-export export default define(meta, paramDef, async (ps, user) => { - while (await UserLists.findOneBy({ + const userList = await UserLists.findOneBy({ + id: ps.listId, userId: user.id, - }) != null) { - const userList = await UserLists.findOneBy({ - // id: ps.listId, - userId: user.id, - }); + }); - if (userList == null) { - throw new ApiError(meta.errors.noSuchList); - } - - await UserLists.delete(userList.id); + if (userList == null) { + throw new ApiError(meta.errors.noSuchList); } + + await UserLists.delete(userList.id); });