fixed status of loading in chat messages
This commit is contained in:
parent
f86cc88e0b
commit
64eb438da7
@ -1,8 +1,8 @@
|
|||||||
import { currentProfile } from "@/lib/current-profile";
|
import { NextResponse } from "next/server";
|
||||||
import { db } from "@/lib/db";
|
|
||||||
import { DirectMessage } from "@prisma/client";
|
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;
|
const MESSAGES_BATCH = 10;
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
messages = await db.directMessage.findMany({
|
messages = await db.directMessage.findMany({
|
||||||
@ -62,8 +62,8 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let nextCursor = null;
|
let nextCursor = null;
|
||||||
@ -74,10 +74,10 @@ export async function GET(
|
|||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
items: messages,
|
items: messages,
|
||||||
nextCursor,
|
nextCursor
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[DIRECT_MESSAGES_GET]", error);
|
console.log("[DIRECT_MESSAGES_GET]", error);
|
||||||
return new NextResponse("Internal Error", { status: 500 })
|
return new NextResponse("Internal Error", { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,7 +45,7 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
messages = await db.message.findMany({
|
messages = await db.message.findMany({
|
||||||
@ -62,8 +62,8 @@ export async function GET(
|
|||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
createdAt: "desc",
|
createdAt: "desc",
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let nextCursor = null;
|
let nextCursor = null;
|
||||||
@ -74,10 +74,10 @@ export async function GET(
|
|||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
items: messages,
|
items: messages,
|
||||||
nextCursor,
|
nextCursor
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[MESSAGES_GET]", error);
|
console.log("[MESSAGES_GET]", error);
|
||||||
return new NextResponse("Internal Error", { status: 500 })
|
return new NextResponse("Internal Error", { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -71,7 +71,7 @@ export const ChatMessages = ({
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (status === "pending") {
|
if (status === "loading") {
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col flex-1 justify-center items-center">
|
<div className="flex flex-col flex-1 justify-center items-center">
|
||||||
<Loader2 className="h-7 w-7 text-zinc-500 animate-spin my-4"/>
|
<Loader2 className="h-7 w-7 text-zinc-500 animate-spin my-4"/>
|
||||||
|
@ -51,11 +51,11 @@ export const ServerSearch = ({
|
|||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
|
||||||
if (type === "member") {
|
if (type === "member") {
|
||||||
return router.push(`/servers/${params.serverId}/conversations/${id}`);
|
return router.push(`/servers/${params?.serverId}/conversations/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === "channel") {
|
if (type === "channel") {
|
||||||
return router.push(`/servers/${params.serverId}/channels/${id}`);
|
return router.push(`/servers/${params?.serverId}/channels/${id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,13 +13,7 @@ const SheetTrigger = SheetPrimitive.Trigger
|
|||||||
|
|
||||||
const SheetClose = SheetPrimitive.Close
|
const SheetClose = SheetPrimitive.Close
|
||||||
|
|
||||||
const SheetPortal = ({
|
const SheetPortal = SheetPrimitive.Portal
|
||||||
className,
|
|
||||||
...props
|
|
||||||
}: SheetPrimitive.DialogPortalProps) => (
|
|
||||||
<SheetPrimitive.Portal className={cn(className)} {...props} />
|
|
||||||
)
|
|
||||||
SheetPortal.displayName = SheetPrimitive.Portal.displayName
|
|
||||||
|
|
||||||
const SheetOverlay = React.forwardRef<
|
const SheetOverlay = React.forwardRef<
|
||||||
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user