added a check to make sure the user actually has the item unlocked
This commit is contained in:
@ -63,17 +63,37 @@ export async function getTrophies() {
|
||||
throw new Error("User is not authenticated or accessCode is missing");
|
||||
}
|
||||
|
||||
const AllStaticTrophies =
|
||||
await artemis.cozynet_chuni_static_trophies.findMany({
|
||||
select: {
|
||||
category: true,
|
||||
netOpenName: true,
|
||||
id: true,
|
||||
str: true,
|
||||
imagePath: true,
|
||||
rareType: true,
|
||||
sortName: true,
|
||||
},
|
||||
});
|
||||
return AllStaticTrophies;
|
||||
const checkIfTrophyIsUnlocked = await artemis.chuni_item_item.findMany({
|
||||
where: {
|
||||
itemKind: 3,
|
||||
user: user.UserId,
|
||||
},
|
||||
select: {
|
||||
itemId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const unlockedTrophies = checkIfTrophyIsUnlocked.map((item) => item.itemId);
|
||||
|
||||
const AllTrophies = await artemis.cozynet_chuni_static_trophies.findMany({
|
||||
select: {
|
||||
category: true,
|
||||
netOpenName: true,
|
||||
id: true,
|
||||
str: true,
|
||||
imagePath: true,
|
||||
rareType: true,
|
||||
sortName: true,
|
||||
},
|
||||
});
|
||||
|
||||
const currentlyUnlockedTrophy = Array.from(
|
||||
new Map(
|
||||
AllTrophies.filter((matchingTrophyId) =>
|
||||
unlockedTrophies.includes(matchingTrophyId.id),
|
||||
).map((unlockedTrophy) => [unlockedTrophy.id, unlockedTrophy]),
|
||||
).values(),
|
||||
);
|
||||
|
||||
return currentlyUnlockedTrophy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user