From dfbd56acc912d1e5c6c9c6f3162614f54046cbf6 Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Mon, 25 Dec 2023 20:43:31 -0500 Subject: [PATCH] minor fix --- components/LinkViews/LinkCard.tsx | 2 -- components/LinkViews/LinkComponents/LinkActions.tsx | 2 +- lib/api/controllers/dashboard/getDashboardData.ts | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/components/LinkViews/LinkCard.tsx b/components/LinkViews/LinkCard.tsx index 3efed9d..232a026 100644 --- a/components/LinkViews/LinkCard.tsx +++ b/components/LinkViews/LinkCard.tsx @@ -62,8 +62,6 @@ export default function LinkGrid({ link, count, className }: Props) { !link.preview?.startsWith("archives") && link.preview !== "unavailable" ) { - getLink(link.id as number); - interval = setInterval(async () => { getLink(link.id as number); }, 5000); diff --git a/components/LinkViews/LinkComponents/LinkActions.tsx b/components/LinkViews/LinkComponents/LinkActions.tsx index 777fe5f..d230373 100644 --- a/components/LinkViews/LinkComponents/LinkActions.tsx +++ b/components/LinkViews/LinkComponents/LinkActions.tsx @@ -114,7 +114,7 @@ export default function LinkActions({ setEditLinkModal(true); }} > - Edit + Edit Link ) : undefined} diff --git a/lib/api/controllers/dashboard/getDashboardData.ts b/lib/api/controllers/dashboard/getDashboardData.ts index c43a869..c75f9c0 100644 --- a/lib/api/controllers/dashboard/getDashboardData.ts +++ b/lib/api/controllers/dashboard/getDashboardData.ts @@ -6,8 +6,8 @@ export default async function getDashboardData( query: LinkRequestQuery ) { let order: any; - if (query.sort === Sort.DateNewestFirst) order = { createdAt: "desc" }; - else if (query.sort === Sort.DateOldestFirst) order = { createdAt: "asc" }; + if (query.sort === Sort.DateNewestFirst) order = { id: "desc" }; + else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" }; else if (query.sort === Sort.NameAZ) order = { name: "asc" }; else if (query.sort === Sort.NameZA) order = { name: "desc" }; else if (query.sort === Sort.DescriptionAZ) order = { description: "asc" }; @@ -42,7 +42,7 @@ export default async function getDashboardData( select: { id: true }, }, }, - orderBy: order || { createdAt: "desc" }, + orderBy: order || { id: "desc" }, }); const recentlyAddedLinks = await prisma.link.findMany({ @@ -67,11 +67,11 @@ export default async function getDashboardData( select: { id: true }, }, }, - orderBy: order || { createdAt: "desc" }, + orderBy: order || { id: "desc" }, }); const links = [...recentlyAddedLinks, ...pinnedLinks].sort( - (a, b) => (new Date(b.createdAt) as any) - (new Date(a.createdAt) as any) + (a, b) => (new Date(b.id) as any) - (new Date(a.id) as any) ); return { response: links, status: 200 };