added a check to make sure the user actually has the item unlocked
This commit is contained in:
@ -61,6 +61,18 @@ export async function getMapIcons() {
|
||||
throw new Error("User is not authenticated or accessCode is missing");
|
||||
}
|
||||
|
||||
const checkIfMapIconIsUnlocked = await artemis.chuni_item_item.findMany({
|
||||
where: {
|
||||
itemKind: 8,
|
||||
user: user.UserId,
|
||||
},
|
||||
select: {
|
||||
itemId: true,
|
||||
},
|
||||
});
|
||||
|
||||
const unlockedMapIcons = checkIfMapIconIsUnlocked.map((item) => item.itemId);
|
||||
|
||||
const AllMapIcons = await artemis.cozynet_chuni_static_mapicon.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
@ -72,5 +84,14 @@ export async function getMapIcons() {
|
||||
netOpenName: true,
|
||||
},
|
||||
});
|
||||
return AllMapIcons;
|
||||
|
||||
const currentlyUnlockedMapIcons = Array.from(
|
||||
new Map(
|
||||
AllMapIcons.filter((matchingMapIconIds) =>
|
||||
unlockedMapIcons.includes(matchingMapIconIds.id),
|
||||
).map((unlockedMapIcons) => [unlockedMapIcons.id, unlockedMapIcons]),
|
||||
).values(),
|
||||
);
|
||||
|
||||
return currentlyUnlockedMapIcons;
|
||||
}
|
||||
|
Reference in New Issue
Block a user