Skip to content

Commit

Permalink
return 404 on broken user page
Browse files Browse the repository at this point in the history
  • Loading branch information
kualta committed Jul 7, 2024
1 parent 14774dc commit dac7bb9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/(sidebars)/u/[user]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LimitType, PublicationType } from "@lens-protocol/client";
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { Feed } from "~/components/Feed";
import { lensItemToPost } from "~/components/post/Post";
import { PostView } from "~/components/post/PostView";
Expand All @@ -19,6 +20,8 @@ const user = async ({ params }: { params: { user: string } }) => {
const handle = params.user;
const { user, posts, nextCursor } = await getInitialData(handle);

if (!user) return notFound();

return (
<Feed
ItemView={PostView}
Expand All @@ -33,6 +36,10 @@ const getInitialData = async (handle: string) => {
const { client } = await getLensClient();
const user = await getUserByHandle(handle);

if (!user) {
return null;
}

const lensPosts = await client.publication
.fetchAll({
where: { from: [user.id], publicationTypes: [PublicationType.Post] },
Expand Down

0 comments on commit dac7bb9

Please sign in to comment.