Skip to content

Commit

Permalink
Add logic to filter out items and jutsu that don't exist
Browse files Browse the repository at this point in the history
Signed-off-by: Phrosfire <65364337+Phrosfire@users.noreply.github.com>
  • Loading branch information
Phrosfire authored Feb 21, 2025
1 parent eaf6bb1 commit f6d2659
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/src/server/api/routers/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ export const profileRouter = createTRPCRouter({
where: and(eq(userData.userId, input.userId), eq(userData.isAi, true)),
with: { jutsus: { with: { jutsu: true } }, items: { with: { item: true } } },
});
// Filter off entries that do not exist
if (user) {
user.jutsus = user.jutsus.filter((j) => j.jutsu);
user.items = user.items.filter((i) => i.item);
}
// Return user
return user ?? null;
}),
// Create new AI
Expand Down Expand Up @@ -970,6 +976,9 @@ export const profileRouter = createTRPCRouter({
if (!requester || !canSeeIps(requester.role)) {
user.lastIp = "hidden";
}
// Filter off entries that do not exist
user.jutsus = user.jutsus.filter((j) => j.jutsu);
user.items = user.items.filter((i) => i.item);
// If no avatarLight version, create one
if (!user.avatarLight && user.avatar) {
const thumbnail = await createThumbnail(user.avatar);
Expand Down

0 comments on commit f6d2659

Please sign in to comment.