From 64eb438da760dfa09875a450af3bdbf51363623a Mon Sep 17 00:00:00 2001 From: Bob Burningham Date: Mon, 13 Nov 2023 00:08:46 -0800 Subject: [PATCH] fixed status of loading in chat messages --- app/api/direct-messages/route.ts | 16 ++++++++-------- app/api/messages/route.ts | 10 +++++----- components/chat/chat-messages.tsx | 2 +- components/server/server-search.tsx | 4 ++-- components/ui/sheet.tsx | 8 +------- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/app/api/direct-messages/route.ts b/app/api/direct-messages/route.ts index 674796e..5996d1e 100644 --- a/app/api/direct-messages/route.ts +++ b/app/api/direct-messages/route.ts @@ -1,8 +1,8 @@ -import { currentProfile } from "@/lib/current-profile"; -import { db } from "@/lib/db"; +import { NextResponse } from "next/server"; import { DirectMessage } from "@prisma/client"; -import { NextResponse } from "next/server"; +import { currentProfile } from "@/lib/current-profile"; +import { db } from "@/lib/db"; const MESSAGES_BATCH = 10; @@ -45,7 +45,7 @@ export async function GET( }, orderBy: { createdAt: "desc", - }, + } }); } else { messages = await db.directMessage.findMany({ @@ -62,8 +62,8 @@ export async function GET( }, orderBy: { createdAt: "desc", - }, - }); + } + }) } let nextCursor = null; @@ -74,10 +74,10 @@ export async function GET( return NextResponse.json({ items: messages, - nextCursor, + nextCursor }); } catch (error) { console.log("[DIRECT_MESSAGES_GET]", error); - return new NextResponse("Internal Error", { status: 500 }) + return new NextResponse("Internal Error", { status: 500 }); } } \ No newline at end of file diff --git a/app/api/messages/route.ts b/app/api/messages/route.ts index 84b8065..065e04d 100644 --- a/app/api/messages/route.ts +++ b/app/api/messages/route.ts @@ -45,7 +45,7 @@ export async function GET( }, orderBy: { createdAt: "desc", - }, + } }); } else { messages = await db.message.findMany({ @@ -62,8 +62,8 @@ export async function GET( }, orderBy: { createdAt: "desc", - }, - }); + } + }) } let nextCursor = null; @@ -74,10 +74,10 @@ export async function GET( return NextResponse.json({ items: messages, - nextCursor, + nextCursor }); } catch (error) { console.log("[MESSAGES_GET]", error); - return new NextResponse("Internal Error", { status: 500 }) + return new NextResponse("Internal Error", { status: 500 }); } } \ No newline at end of file diff --git a/components/chat/chat-messages.tsx b/components/chat/chat-messages.tsx index 84f3c54..07fb464 100644 --- a/components/chat/chat-messages.tsx +++ b/components/chat/chat-messages.tsx @@ -71,7 +71,7 @@ export const ChatMessages = ({ }) - if (status === "pending") { + if (status === "loading") { return (
diff --git a/components/server/server-search.tsx b/components/server/server-search.tsx index cb6f1a9..6cbc7d2 100644 --- a/components/server/server-search.tsx +++ b/components/server/server-search.tsx @@ -51,11 +51,11 @@ export const ServerSearch = ({ setOpen(false); if (type === "member") { - return router.push(`/servers/${params.serverId}/conversations/${id}`); + return router.push(`/servers/${params?.serverId}/conversations/${id}`); } if (type === "channel") { - return router.push(`/servers/${params.serverId}/channels/${id}`); + return router.push(`/servers/${params?.serverId}/channels/${id}`); } } diff --git a/components/ui/sheet.tsx b/components/ui/sheet.tsx index 3e98e6f..6a95894 100644 --- a/components/ui/sheet.tsx +++ b/components/ui/sheet.tsx @@ -13,13 +13,7 @@ const SheetTrigger = SheetPrimitive.Trigger const SheetClose = SheetPrimitive.Close -const SheetPortal = ({ - className, - ...props -}: SheetPrimitive.DialogPortalProps) => ( - -) -SheetPortal.displayName = SheetPrimitive.Portal.displayName +const SheetPortal = SheetPrimitive.Portal const SheetOverlay = React.forwardRef< React.ElementRef,