added a check to make sure the user actually has the item unlocked
This commit is contained in:
@ -63,6 +63,20 @@ export async function getNamePlates() {
|
||||
throw new Error("User is not authenticated or accessCode is missing");
|
||||
}
|
||||
|
||||
const checkIfNamePlatetIsUnlocked = await artemis.chuni_item_item.findMany({
|
||||
where: {
|
||||
itemKind: 1,
|
||||
user: user.UserId,
|
||||
},
|
||||
select: {
|
||||
itemId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const unlockedNamePlates = checkIfNamePlatetIsUnlocked.map(
|
||||
(item) => item.itemId,
|
||||
);
|
||||
|
||||
const AllNameplates = await artemis.cozynet_chuni_static_nameplate.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
@ -74,5 +88,17 @@ export async function getNamePlates() {
|
||||
netOpenName: true,
|
||||
},
|
||||
});
|
||||
return AllNameplates;
|
||||
|
||||
const currentlyUnlockedNamePlates = Array.from(
|
||||
new Map(
|
||||
AllNameplates.filter((matchingNamePlateIds) =>
|
||||
unlockedNamePlates.includes(matchingNamePlateIds.id),
|
||||
).map((unlockedNamePlates) => [
|
||||
unlockedNamePlates.id,
|
||||
unlockedNamePlates,
|
||||
]),
|
||||
).values(),
|
||||
);
|
||||
|
||||
return currentlyUnlockedNamePlates;
|
||||
}
|
||||
|
Reference in New Issue
Block a user