diff --git a/app/routes/mod-queue.tsx b/app/routes/mod-queue.tsx index b202afb..e15cca2 100644 --- a/app/routes/mod-queue.tsx +++ b/app/routes/mod-queue.tsx @@ -147,7 +147,7 @@ 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 ( @@ -155,20 +155,27 @@ export default function () { 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); + } } }