Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add before param to update queue
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent d9fcec9 commit 8b18454
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/routes/mod-queue.tsx
Expand Up @@ -81,6 +81,7 @@ export default function () {
const isDesktop = useBreakpointValue({ base: false, lg: true });
const entryTypes = [];
const [entries, setEntries] = useState([] as JSX.Element[]);
const [before, setBefore] = useState(0);

for (const type of pageProps.entry_types)
entryTypes.push(
Expand All @@ -91,10 +92,11 @@ export default function () {

async function updateQueue(
queue_type: string,
show_closed: boolean = false
before = 0,
show_closed = false
): Promise<void> {
const queueReq = await fetch(
`/api/mod-queue/list?type=${queue_type}&showClosed=${show_closed}`
`/api/mod-queue/list?before=${before}&showClosed=${show_closed}&type=${queue_type}`
);

if (!queueReq.ok) {
Expand All @@ -112,7 +114,7 @@ export default function () {
}

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

for (const entry of entryData) {
switch (queue_type) {
Expand All @@ -134,6 +136,7 @@ export default function () {
}

setEntries(newEntries);
setBefore(entryData[entryData.length - 1].created_at);
}

return (
Expand Down

0 comments on commit 8b18454

Please sign in to comment.