Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions i18n/locales/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@
"add": "Add",
"cannotUndo": "This action cannot be undone.",
"close": "Close",
"components": {
"multiitem": {
"new": "Create new: \"{0}\"",
"placeholder": "Start typing..."
}
},
"create": "Create",
"date": "Date",
"delete": "Delete",
Expand All @@ -181,13 +187,7 @@
"servers": "Servers",
"srLoading": "Loading…",
"tags": "Tags",
"today": "Today",
"components": {
"multiitem": {
"placeholder": "Start typing...",
"new": "Create new: \"{0}\""
}
}
"today": "Today"
},
"drop": {
"desc": "An open-source game distribution platform built for speed, flexibility and beauty.",
Expand Down
14 changes: 12 additions & 2 deletions server/api/v1/admin/game/[id]/tags.patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ export default defineEventHandler(async (h3) => {

const game = await prisma.game.findUnique({
where: { id },
select: { id: true },
select: { id: true, tags: { select: { id: true } } },
});
if (!game) throw createError({ statusCode: 404, message: "Game not found" });

const tagSet = new Set(game.tags.map((v) => v.id));
const toConnect = body.tags.filter((v) => !tagSet.has(v));

const bodyTagSet = new Set(body.tags);
const toDisconnect = tagSet
.values()
.filter((v) => !bodyTagSet.has(v))
.toArray();

// SAFETY: Okay to disable due to check above
// eslint-disable-next-line drop/no-prisma-delete
await prisma.game.update({
Expand All @@ -28,7 +37,8 @@ export default defineEventHandler(async (h3) => {
},
data: {
tags: {
connect: body.tags.map((e) => ({ id: e })),
connect: toConnect.map((e) => ({ id: e })),
disconnect: toDisconnect.map((e) => ({ id: e })),
},
},
});
Expand Down
Loading