fixed status of loading in chat messages

This commit is contained in:
Bob Burningham 2023-11-13 00:08:46 -08:00
parent f86cc88e0b
commit 64eb438da7
5 changed files with 17 additions and 23 deletions

View File

@ -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 });
}
}

View File

@ -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 });
}
}

View File

@ -71,7 +71,7 @@ export const ChatMessages = ({
})
if (status === "pending") {
if (status === "loading") {
return (
<div className="flex flex-col flex-1 justify-center items-center">
<Loader2 className="h-7 w-7 text-zinc-500 animate-spin my-4"/>

View File

@ -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}`);
}
}

View File

@ -13,13 +13,7 @@ const SheetTrigger = SheetPrimitive.Trigger
const SheetClose = SheetPrimitive.Close
const SheetPortal = ({
className,
...props
}: SheetPrimitive.DialogPortalProps) => (
<SheetPrimitive.Portal className={cn(className)} {...props} />
)
SheetPortal.displayName = SheetPrimitive.Portal.displayName
const SheetPortal = SheetPrimitive.Portal
const SheetOverlay = React.forwardRef<
React.ElementRef<typeof SheetPrimitive.Overlay>,