Skip to content

Commit

Permalink
πŸ” Rename publication to post for v3 preparation: v2 (#pre-lens-v3)
Browse files Browse the repository at this point in the history
Summary: Renamed "publication" to "post" and updated related helper functions for v3.

Highlights:

β€’ Replaced `isMirrorPublication` with `isRepost` in components and helpers.
β€’ Updated component props from `publication` to `post`.
β€’ Added `postHelpers.spec.ts` for testing new helper functions.

Read more: https://pierre.co/hey/hey/pre-lens-v3
  • Loading branch information
Yoginth authored and Pierre committed Nov 13, 2024
1 parent 8e451b9 commit c293673
Show file tree
Hide file tree
Showing 46 changed files with 321 additions and 387 deletions.
30 changes: 14 additions & 16 deletions apps/og/src/app/posts/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { APP_NAME } from "@hey/data/constants";
import getPostData from "@hey/helpers/getPostData";
import getProfile from "@hey/helpers/getProfile";
import logger from "@hey/helpers/logger";
import { isMirrorPublication } from "@hey/helpers/publicationHelpers";
import { isRepost } from "@hey/helpers/postHelpers";
import type { AnyPublication } from "@hey/lens";
import { PublicationDocument } from "@hey/lens";
import { addTypenameToDocument } from "apollo-utilities";
Expand Down Expand Up @@ -39,20 +39,18 @@ export const generateMetadata = async ({
}

const publication = result.data.publication as AnyPublication;
const targetPublication = isMirrorPublication(publication)
? publication.mirrorOn
: publication;
const { by: profile, metadata } = targetPublication;
const targetPost = isRepost(publication) ? publication.mirrorOn : publication;
const { by: profile, metadata } = targetPost;
const filteredContent = getPostData(metadata)?.content || "";
const filteredAsset = getPostData(metadata)?.asset;
const assetIsAudio = filteredAsset?.type === "Audio";

const { displayName, link, slugWithPrefix } = getProfile(profile);
const title = `${targetPublication.__typename} by ${slugWithPrefix} β€’ ${APP_NAME}`;
const title = `${targetPost.__typename} by ${slugWithPrefix} β€’ ${APP_NAME}`;
const description = (filteredContent || title).slice(0, 155);

return {
alternates: { canonical: `https://hey.xyz/posts/${targetPublication.id}` },
alternates: { canonical: `https://hey.xyz/posts/${targetPost.id}` },
applicationName: APP_NAME,
authors: {
name: displayName,
Expand All @@ -79,22 +77,22 @@ export const generateMetadata = async ({
displayName,
slugWithPrefix
],
metadataBase: new URL(`https://hey.xyz/posts/${targetPublication.id}`),
metadataBase: new URL(`https://hey.xyz/posts/${targetPost.id}`),
openGraph: {
description: description,
images: getPublicationOGImages(metadata) as any,
siteName: "Hey",
type: "article",
url: `https://hey.xyz/posts/${targetPublication.id}`
url: `https://hey.xyz/posts/${targetPost.id}`
},
other: {
"count:actions": targetPublication.stats.countOpenActions,
"count:comments": targetPublication.stats.comments,
"count:likes": targetPublication.stats.reactions,
"count:mirrors": targetPublication.stats.mirrors,
"count:quotes": targetPublication.stats.quotes,
"lens:id": targetPublication.id,
...getCollectModuleMetadata(targetPublication)
"count:actions": targetPost.stats.countOpenActions,
"count:comments": targetPost.stats.comments,
"count:likes": targetPost.stats.reactions,
"count:mirrors": targetPost.stats.mirrors,
"count:quotes": targetPost.stats.quotes,
"lens:id": targetPost.id,
...getCollectModuleMetadata(targetPost)
},
publisher: displayName,
title: title,
Expand Down
14 changes: 7 additions & 7 deletions apps/web/src/components/Bookmarks/BookmarksFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const BookmarksFeed: FC<BookmarksFeedProps> = ({ focus }) => {
variables: { request }
});

const publications = data?.publicationBookmarks?.items;
const posts = data?.publicationBookmarks?.items;
const pageInfo = data?.publicationBookmarks?.pageInfo;
const hasMore = pageInfo?.next;

Expand Down Expand Up @@ -73,7 +73,7 @@ const BookmarksFeed: FC<BookmarksFeedProps> = ({ focus }) => {
return <PostsShimmer />;
}

if (publications?.length === 0) {
if (posts?.length === 0) {
return (
<EmptyState
icon={<BookmarkIcon className="size-8" />}
Expand All @@ -90,15 +90,15 @@ const BookmarksFeed: FC<BookmarksFeedProps> = ({ focus }) => {
<Card>
<Virtuoso
className="virtual-divider-list-window"
computeItemKey={(index, publication) => `${publication.id}-${index}`}
data={publications}
computeItemKey={(index, post) => `${post.id}-${index}`}
data={posts}
endReached={onEndReached}
isScrolling={onScrolling}
itemContent={(index, publication) => (
itemContent={(index, post) => (
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
isLast={index === (posts?.length || 0) - 1}
post={post as AnyPublication}
/>
)}
ref={virtuoso}
Expand Down
14 changes: 7 additions & 7 deletions apps/web/src/components/Club/ClubFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ClubFeed: FC<ClubFeedProps> = ({ handle }) => {
variables: { request }
});

const publications = data?.publications?.items;
const posts = data?.publications?.items;
const pageInfo = data?.publications?.pageInfo;
const hasMore = pageInfo?.next;

Expand Down Expand Up @@ -74,7 +74,7 @@ const ClubFeed: FC<ClubFeedProps> = ({ handle }) => {
return <PostsShimmer />;
}

if (publications?.length === 0) {
if (posts?.length === 0) {
return (
<EmptyState
icon={<ChatBubbleBottomCenterIcon className="size-8" />}
Expand All @@ -96,15 +96,15 @@ const ClubFeed: FC<ClubFeedProps> = ({ handle }) => {
<Card>
<Virtuoso
className="virtual-divider-list-window"
computeItemKey={(index, publication) => `${publication.id}-${index}`}
data={publications}
computeItemKey={(index, post) => `${post.id}-${index}`}
data={posts}
endReached={onEndReached}
isScrolling={onScrolling}
itemContent={(index, publication) => (
itemContent={(index, post) => (
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
isLast={index === (posts?.length || 0) - 1}
post={post as AnyPublication}
/>
)}
ref={virtuoso}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Comment/CommentFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const CommentFeed: FC<CommentFeedProps> = ({ publicationId }) => {
<SinglePost
isFirst={isFirst}
isLast={isLast}
publication={comment as Comment}
post={comment as Comment}
showType={false}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Comment/NoneRelevantFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const NoneRelevantFeed: FC<NoneRelevantFeedProps> = ({ publicationId }) => {
<SinglePost
isFirst={isFirst}
isLast={isLast}
publication={comment as Comment}
post={comment as Comment}
showType={false}
/>
);
Expand Down
5 changes: 1 addition & 4 deletions apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,7 @@ const NewPublication: FC<NewPublicationProps> = ({
<NewAttachments attachments={attachments} />
{quotedPublication ? (
<Wrapper className="m-5" zeroPadding>
<QuotedPost
isNew
publication={removeQuoteOn(quotedPublication as Quote)}
/>
<QuotedPost isNew post={removeQuoteOn(quotedPublication as Quote)} />
</Wrapper>
) : null}
<div className="divider mx-5" />
Expand Down
14 changes: 7 additions & 7 deletions apps/web/src/components/Explore/ExploreFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ExploreFeed: FC<ExploreFeedProps> = ({
variables: { request }
});

const publications = data?.explorePublications?.items;
const posts = data?.explorePublications?.items;
const pageInfo = data?.explorePublications?.pageInfo;
const hasMore = pageInfo?.next;

Expand All @@ -80,7 +80,7 @@ const ExploreFeed: FC<ExploreFeedProps> = ({
return <PostsShimmer />;
}

if (publications?.length === 0) {
if (posts?.length === 0) {
return (
<EmptyState
icon={<ChatBubbleBottomCenterIcon className="size-8" />}
Expand All @@ -97,15 +97,15 @@ const ExploreFeed: FC<ExploreFeedProps> = ({
<Card>
<Virtuoso
className="virtual-divider-list-window"
computeItemKey={(index, publication) => `${publication.id}-${index}`}
data={publications}
computeItemKey={(index, post) => `${post.id}-${index}`}
data={posts}
endReached={onEndReached}
isScrolling={onScrolling}
itemContent={(index, publication) => (
itemContent={(index, post) => (
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
isLast={index === (posts?.length || 0) - 1}
post={post as AnyPublication}
/>
)}
ref={virtuoso}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/ForYou.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const ForYou: FC = () => {
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={item.publication as AnyPublication}
post={item.publication as AnyPublication}
/>
)}
useWindowScroll
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SmallSingleProfile from "@components/Shared/SmallSingleProfile";
import getCollectModuleData from "@hey/helpers/getCollectModuleData";
import getTokenImage from "@hey/helpers/getTokenImage";
import { isMirrorPublication } from "@hey/helpers/publicationHelpers";
import { isRepost } from "@hey/helpers/postHelpers";
import type {
AnyPublication,
LatestActed,
Expand All @@ -19,11 +19,9 @@ const OpenActionPaidAction: FC<OpenActionPaidActionProps> = ({
latestActed,
publication
}) => {
const targetPublication = isMirrorPublication(publication)
? publication.mirrorOn
: publication;
const targetPost = isRepost(publication) ? publication.mirrorOn : publication;

const openActions = targetPublication.openActionModules
const openActions = targetPost.openActionModules
.filter(
(module) =>
module.__typename === "MultirecipientFeeCollectOpenActionSettings" ||
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/PaidActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const PaidActions: FC = () => {
<SinglePost
isFirst={false}
isLast
publication={action.actedOn as AnyPublication}
post={action.actedOn as AnyPublication}
showThread={false}
/>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Home/Timeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Timeline: FC = () => {
feedItem={feedItem as FeedItem}
isFirst={index === 0}
isLast={index === (feed?.length || 0) - 1}
publication={feedItem.root as AnyPublication}
post={feedItem.root as AnyPublication}
/>
)}
ref={virtuoso}
Expand Down
14 changes: 7 additions & 7 deletions apps/web/src/components/List/ListFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const ListFeed: FC<ListFeedProps> = ({ list, showHeader = false }) => {
variables: { request }
});

const publications = publicationsData?.publications?.items || [];
const posts = publicationsData?.publications?.items || [];

const onScrolling = (scrolling: boolean) => {
if (!scrolling) {
Expand Down Expand Up @@ -107,7 +107,7 @@ const ListFeed: FC<ListFeedProps> = ({ list, showHeader = false }) => {
);
};

if (publications?.length === 0) {
if (posts?.length === 0) {
return (
<Card>
<Header />
Expand Down Expand Up @@ -137,14 +137,14 @@ const ListFeed: FC<ListFeedProps> = ({ list, showHeader = false }) => {
<Header />
<Virtuoso
className="virtual-divider-list-window"
computeItemKey={(index, publication) => `${publication.id}-${index}`}
data={publications}
computeItemKey={(index, post) => `${post.id}-${index}`}
data={posts}
isScrolling={onScrolling}
itemContent={(index, publication) => (
itemContent={(index, post) => (
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
isLast={index === (posts?.length || 0) - 1}
post={post as AnyPublication}
/>
)}
ref={virtuoso}
Expand Down
17 changes: 8 additions & 9 deletions apps/web/src/components/Mod/LatestFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const LatestFeed: FC = () => {
const { data, error, fetchMore, loading, refetch } =
useModExplorePublicationsQuery({ variables: { request } });

const publications = data?.modExplorePublications?.items;
const posts = data?.modExplorePublications?.items;
const pageInfo = data?.modExplorePublications?.pageInfo;
const hasMore = pageInfo?.next;

Expand All @@ -68,7 +68,7 @@ const LatestFeed: FC = () => {
return <PostsShimmer />;
}

if (publications?.length === 0) {
if (posts?.length === 0) {
return (
<EmptyState
icon={<ChatBubbleBottomCenterIcon className="size-8" />}
Expand All @@ -87,23 +87,22 @@ const LatestFeed: FC = () => {
<Virtuoso
className="[&>div>div]:space-y-5"
components={{ Footer: () => <div className="pb-5" /> }}
computeItemKey={(index, publication) => `${publication.id}-${index}`}
data={publications?.filter(
(publication) =>
!SKIPPED_PROFILE_IDS.includes(publication?.by?.id as string)
computeItemKey={(index, post) => `${post.id}-${index}`}
data={posts?.filter(
(post) => !SKIPPED_PROFILE_IDS.includes(post?.by?.id as string)
)}
endReached={onEndReached}
itemContent={(_, publication) => (
itemContent={(_, post) => (
<Card>
<SinglePost
isFirst
isLast={false}
publication={publication as AnyPublication}
post={post as AnyPublication}
showActions={false}
showThread={false}
/>
<div className="divider" />
<HigherActions publication={publication as MirrorablePublication} />
<HigherActions publication={post as MirrorablePublication} />
</Card>
)}
useWindowScroll
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Mod/ReportsFeed/Reports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const Reports: FC<ReportsProps> = ({ profileId, publicationId }) => {
<Card>
<SinglePost
isFirst
publication={report.reportedPublication as AnyPublication}
post={report.reportedPublication as AnyPublication}
showActions={false}
showThread={false}
/>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Mod/ReportsFeed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const ReportsFeed: FC = () => {
<Card>
<SinglePost
isFirst
publication={report.reportedPublication as AnyPublication}
post={report.reportedPublication as AnyPublication}
showActions={false}
showThread={false}
/>
Expand Down
Loading

1 comment on commit c293673

@vercel
Copy link

@vercel vercel bot commented on c293673 Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./

heyxyz.vercel.app
hey.xyz
web-heyxyz.vercel.app
web-git-main-heyxyz.vercel.app

Please sign in to comment.