Skip to content

Commit

Permalink
make posts user nav default
Browse files Browse the repository at this point in the history
  • Loading branch information
kualta committed Jun 27, 2024
1 parent 2cba625 commit ebc28ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LimitType, PublicationType } from "@lens-protocol/client";
import { LimitType } from "@lens-protocol/client";
import type { Metadata } from "next";
import { InfiniteScroll } from "~/components/InfiniteScroll";
import { lensItemToPost } from "~/components/post/Post";
Expand All @@ -10,17 +10,15 @@ export async function generateMetadata({ params }: { params: { user: string } })
const title = `${handle}`;
return {
title,
description: `@${handle}'s comments on Pingpad`,
description: `@${handle} on Pingpad`,
};
}

const user = async ({ params }: { params: { user: string } }) => {
const handle = params.user;
const { user, posts, nextCursor } = await getInitialData(handle);

return (
<InfiniteScroll endpoint={`/api/posts?id=${user.id}&type=post`} initialData={posts} initialCursor={nextCursor} />
);
return <InfiniteScroll endpoint={`/api/posts?id=${user.id}`} initialData={posts} initialCursor={nextCursor} />;
};

const getInitialData = async (handle: string) => {
Expand All @@ -29,7 +27,7 @@ const getInitialData = async (handle: string) => {

const lensPosts = await client.publication
.fetchAll({
where: { from: [user.id], publicationTypes: [PublicationType.Post] },
where: { from: [user.id] },
limit: LimitType.Ten,
})
.catch(() => {
Expand Down
6 changes: 4 additions & 2 deletions src/app/(sidebars)/u/[user]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ const user = async ({ params }: { params: { user: string } }) => {
const handle = params.user;
const { user, posts, nextCursor } = await getInitialData(handle);

return <InfiniteScroll endpoint={`/api/posts?id=${user.id}`} initialData={posts} initialCursor={nextCursor} />;
return (
<InfiniteScroll endpoint={`/api/posts?id=${user.id}&type=post`} initialData={posts} initialCursor={nextCursor} />
);
};

const getInitialData = async (handle: string) => {
Expand All @@ -27,7 +29,7 @@ const getInitialData = async (handle: string) => {

const lensPosts = await client.publication
.fetchAll({
where: { from: [user.id] },
where: { from: [user.id], publicationTypes: [PublicationType.Post] },
limit: LimitType.Ten,
})
.catch(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/user/UserNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ export const UserNavigation = ({ handle }: { handle: string }) => {
return (
<nav className="z-[40] flex flex-row justify-start items-center gap-2 pt-2 px-4">
<NavigationItem href={`/u/${handle}`}>
<MessageCircleCode size={18} />
all
</NavigationItem>
<NavigationItem href={`/u/${handle}/posts`}>
<MessageCircle size={18} />
posts
</NavigationItem>
<NavigationItem href={`/u/${handle}/comments`}>
<MessageSquare size={18} />
comments
</NavigationItem>
<NavigationItem href={`/u/${handle}/all`}>
<MessageCircleCode size={18} />
all
</NavigationItem>
<NavigationItem href={`/u/${handle}/gallery`} disabled>
<ImagesIcon size={18} />
gallery
Expand Down

0 comments on commit ebc28ba

Please sign in to comment.