Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
what could go wrong kekw
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 03c2cf1 commit e2b2aad
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions app/routes/mod-queue.tsx
Expand Up @@ -147,28 +147,35 @@ export default function () {
const itemId = searchParams.get("id");
const itemType = searchParams.get("type");

const entryData: { [k: string]: any }[] = await queueReq.json();
let entryData: { [k: string]: any }[] = await queueReq.json();
const newEntries = [...entries];

if (
itemId &&
itemType &&
["appeal", "gma", "inactivity", "report"].includes(itemType)
) {
const itemReq = await fetch(`/api/mod-queue/${itemType}/${itemId}`);

if (!itemReq.ok) {
toast({
description: ((await itemReq.json()) as { error: string }).error,
duration: 10000,
isClosable: true,
status: "error",
title: "Failed to load item with id " + itemId,
});
} else {
const itemData: { [k: string]: any } = await itemReq.json();
const specifiedItem = entryData.find((e) => e.id === itemId);

entryData.unshift(itemData);
if (specifiedItem) {
entryData = entryData.filter((entry) => entry.id !== specifiedItem.id);
entryData.unshift(specifiedItem);
} else {
const itemReq = await fetch(`/api/mod-queue/${itemType}/${itemId}`);

if (!itemReq.ok) {
toast({
description: ((await itemReq.json()) as { error: string }).error,
duration: 10000,
isClosable: true,
status: "error",
title: "Failed to load item with id " + itemId,
});
} else {
const itemData: { [k: string]: any } = await itemReq.json();

entryData.unshift(itemData);
}
}
}

Expand Down

0 comments on commit e2b2aad

Please sign in to comment.