Skip to content

Commit

Permalink
πŸ” Rename publication to post for v3 preparation (#pre-lens-v3)
Browse files Browse the repository at this point in the history
Summary: Renamed components and helpers from "Publication" to "Post" for v3 preparation.

Highlights:

β€’ Introduced `PostHeader`, `PostStats`, `QueuedPost`, and `QuotedPost` components.
β€’ Replaced `Publication` references with `Post` in components and helper functions.
β€’ Added `getPostData` and `isPostMetadataTypeAllowed` helper functions with tests.

Read more: https://pierre.co/hey/hey/pre-lens-v3
  • Loading branch information
Yoginth authored and Pierre committed Nov 13, 2024
1 parent a6cb4e0 commit 8e451b9
Show file tree
Hide file tree
Showing 62 changed files with 292 additions and 313 deletions.
6 changes: 3 additions & 3 deletions apps/og/src/app/posts/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import getCollectModuleMetadata from "@helpers/getCollectModuleMetadata";
import getPublicationOGImages from "@helpers/getPublicationOGImages";
import { APP_NAME } from "@hey/data/constants";
import getPostData from "@hey/helpers/getPostData";
import getProfile from "@hey/helpers/getProfile";
import getPublicationData from "@hey/helpers/getPublicationData";
import logger from "@hey/helpers/logger";
import { isMirrorPublication } from "@hey/helpers/publicationHelpers";
import type { AnyPublication } from "@hey/lens";
Expand Down Expand Up @@ -43,8 +43,8 @@ export const generateMetadata = async ({
? publication.mirrorOn
: publication;
const { by: profile, metadata } = targetPublication;
const filteredContent = getPublicationData(metadata)?.content || "";
const filteredAsset = getPublicationData(metadata)?.asset;
const filteredContent = getPostData(metadata)?.content || "";
const filteredAsset = getPostData(metadata)?.asset;
const assetIsAudio = filteredAsset?.type === "Audio";

const { displayName, link, slugWithPrefix } = getProfile(profile);
Expand Down
16 changes: 8 additions & 8 deletions apps/og/src/helpers/getPublicationOGImages.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import getPublicationData from "@hey/helpers/getPublicationData";
import getPostData from "@hey/helpers/getPostData";
import { beforeEach, describe, expect, test, vi } from "vitest";
import getPublicationOGImages from "./getPublicationOGImages";

vi.mock("@hey/helpers/getPublicationData", () => ({
vi.mock("@hey/helpers/getPostData", () => ({
default: vi.fn()
}));

Expand All @@ -21,7 +21,7 @@ describe("getPublicationOGImages", () => {
asset: { type: "Image", uri: "https://example.com/asset-image.jpg" }
};

(getPublicationData as any).mockReturnValue(mockPublicationData);
(getPostData as any).mockReturnValue(mockPublicationData);

const result = getPublicationOGImages(mockMetadata);
expect(result).toEqual([
Expand All @@ -37,7 +37,7 @@ describe("getPublicationOGImages", () => {
asset: { type: "Image", uri: "https://example.com/asset-image.jpg" }
};

(getPublicationData as any).mockReturnValue(mockPublicationData);
(getPostData as any).mockReturnValue(mockPublicationData);

const result = getPublicationOGImages(mockMetadata);
expect(result).toEqual(["https://example.com/asset-image.jpg"]);
Expand All @@ -50,7 +50,7 @@ describe("getPublicationOGImages", () => {
asset: { type: "Video", cover: "https://example.com/video-cover.jpg" }
};

(getPublicationData as any).mockReturnValue(mockPublicationData);
(getPostData as any).mockReturnValue(mockPublicationData);

const result = getPublicationOGImages(mockMetadata);
expect(result).toEqual(["https://example.com/video-cover.jpg"]);
Expand All @@ -63,7 +63,7 @@ describe("getPublicationOGImages", () => {
asset: { type: "Audio", cover: "https://example.com/audio-cover.jpg" }
};

(getPublicationData as any).mockReturnValue(mockPublicationData);
(getPostData as any).mockReturnValue(mockPublicationData);

const result = getPublicationOGImages(mockMetadata);
expect(result).toEqual(["https://example.com/audio-cover.jpg"]);
Expand All @@ -79,7 +79,7 @@ describe("getPublicationOGImages", () => {
asset: { type: "Video", cover: "https://example.com/video-cover.jpg" }
};

(getPublicationData as any).mockReturnValue(mockPublicationData);
(getPostData as any).mockReturnValue(mockPublicationData);

const result = getPublicationOGImages(mockMetadata);
expect(result).toEqual([
Expand All @@ -91,7 +91,7 @@ describe("getPublicationOGImages", () => {
test("should return empty array if no valid data is present", () => {
const mockMetadata = { __typename: "TextOnlyMetadata" } as any;

(getPublicationData as any).mockReturnValue({ attachments: [], asset: {} });
(getPostData as any).mockReturnValue({ attachments: [], asset: {} });

const result = getPublicationOGImages(mockMetadata);
expect(result).toEqual([]);
Expand Down
6 changes: 3 additions & 3 deletions apps/og/src/helpers/getPublicationOGImages.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import getPublicationData from "@hey/helpers/getPublicationData";
import getPostData from "@hey/helpers/getPostData";
import type { PublicationMetadata } from "@hey/lens";

const getPublicationOGImages = (metadata: PublicationMetadata) => {
const filteredAttachments = getPublicationData(metadata)?.attachments || [];
const filteredAsset = getPublicationData(metadata)?.asset;
const filteredAttachments = getPostData(metadata)?.attachments || [];
const filteredAsset = getPostData(metadata)?.asset;

const assetIsImage = filteredAsset?.type === "Image";
const assetIsVideo = filteredAsset?.type === "Video";
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Bookmarks/BookmarksFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SinglePublication from "@components/Publication/SinglePublication";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import SinglePost from "@components/Publication/SinglePost";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import { BookmarkIcon } from "@heroicons/react/24/outline";
import type {
AnyPublication,
Expand Down Expand Up @@ -70,7 +70,7 @@ const BookmarksFeed: FC<BookmarksFeedProps> = ({ focus }) => {
};

if (loading) {
return <PublicationsShimmer />;
return <PostsShimmer />;
}

if (publications?.length === 0) {
Expand All @@ -95,7 +95,7 @@ const BookmarksFeed: FC<BookmarksFeedProps> = ({ focus }) => {
endReached={onEndReached}
isScrolling={onScrolling}
itemContent={(index, publication) => (
<SinglePublication
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Club/ClubFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SinglePublication from "@components/Publication/SinglePublication";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import SinglePost from "@components/Publication/SinglePost";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import { ChatBubbleBottomCenterIcon } from "@heroicons/react/24/outline";
import type { AnyPublication, PublicationsRequest } from "@hey/lens";
import { LimitType, usePublicationsQuery } from "@hey/lens";
Expand Down Expand Up @@ -71,7 +71,7 @@ const ClubFeed: FC<ClubFeedProps> = ({ handle }) => {
};

if (loading) {
return <PublicationsShimmer />;
return <PostsShimmer />;
}

if (publications?.length === 0) {
Expand Down Expand Up @@ -101,7 +101,7 @@ const ClubFeed: FC<ClubFeedProps> = ({ handle }) => {
endReached={onEndReached}
isScrolling={onScrolling}
itemContent={(index, publication) => (
<SinglePublication
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Club/Shimmer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import ProfileListShimmer from "@components/Shared/Shimmer/ProfileListShimmer";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import { Card, GridItemEight, GridItemFour, GridLayout } from "@hey/ui";
import type { FC } from "react";

Expand Down Expand Up @@ -42,7 +42,7 @@ const ClubPageShimmer: FC<ClubPageShimmerProps> = ({ profileList = false }) => {
<ProfileListShimmer />
</Card>
) : (
<PublicationsShimmer />
<PostsShimmer />
)}
</GridItemEight>
</GridLayout>
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/components/Comment/CommentFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useHiddenCommentFeedStore } from "@components/Publication";
import QueuedPublication from "@components/Publication/QueuedPublication";
import SinglePublication from "@components/Publication/SinglePublication";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import QueuedPost from "@components/Publication/QueuedPost";
import SinglePost from "@components/Publication/SinglePost";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import { ChatBubbleLeftIcon } from "@heroicons/react/24/outline";
import type { Comment, PublicationsRequest } from "@hey/lens";
import {
Expand Down Expand Up @@ -81,7 +81,7 @@ const CommentFeed: FC<CommentFeedProps> = ({ publicationId }) => {
};

if (loading) {
return <PublicationsShimmer />;
return <PostsShimmer />;
}

if (error) {
Expand All @@ -100,7 +100,7 @@ const CommentFeed: FC<CommentFeedProps> = ({ publicationId }) => {
return (
<>
{queuedComments.map((txn) => (
<QueuedPublication key={txn.txId} txn={txn} />
<QueuedPost key={txn.txId} txn={txn} />
))}
<Card>
<Virtuoso
Expand All @@ -119,7 +119,7 @@ const CommentFeed: FC<CommentFeedProps> = ({ publicationId }) => {
const isLast = index === comments.length - 1;

return (
<SinglePublication
<SinglePost
isFirst={isFirst}
isLast={isLast}
publication={comment as Comment}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Comment/NoneRelevantFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useHiddenCommentFeedStore } from "@components/Publication";
import SinglePublication from "@components/Publication/SinglePublication";
import SinglePost from "@components/Publication/SinglePost";
import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/react/24/outline";
import getAvatar from "@hey/helpers/getAvatar";
import type { Comment, PublicationsRequest } from "@hey/lens";
Expand Down Expand Up @@ -106,7 +106,7 @@ const NoneRelevantFeed: FC<NoneRelevantFeedProps> = ({ publicationId }) => {
const isLast = index === comments.length - 1;

return (
<SinglePublication
<SinglePost
isFirst={isFirst}
isLast={isLast}
publication={comment as Comment}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NewAttachments from "@components/Composer/NewAttachments";
import QuotedPublication from "@components/Publication/QuotedPublication";
import QuotedPost from "@components/Publication/QuotedPost";
import { AudioPublicationSchema } from "@components/Shared/Audio";
import Wrapper from "@components/Shared/Embed/Wrapper";
import errorToast from "@helpers/errorToast";
Expand Down Expand Up @@ -524,7 +524,7 @@ const NewPublication: FC<NewPublicationProps> = ({
<NewAttachments attachments={attachments} />
{quotedPublication ? (
<Wrapper className="m-5" zeroPadding>
<QuotedPublication
<QuotedPost
isNew
publication={removeQuoteOn(quotedPublication as Quote)}
/>
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Explore/ExploreFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SinglePublication from "@components/Publication/SinglePublication";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import SinglePost from "@components/Publication/SinglePost";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import { ChatBubbleBottomCenterIcon } from "@heroicons/react/24/outline";
import type {
AnyPublication,
Expand Down Expand Up @@ -77,7 +77,7 @@ const ExploreFeed: FC<ExploreFeedProps> = ({
};

if (loading) {
return <PublicationsShimmer />;
return <PostsShimmer />;
}

if (publications?.length === 0) {
Expand All @@ -102,7 +102,7 @@ const ExploreFeed: FC<ExploreFeedProps> = ({
endReached={onEndReached}
isScrolling={onScrolling}
itemContent={(index, publication) => (
<SinglePublication
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/components/Home/ForYou.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QueuedPublication from "@components/Publication/QueuedPublication";
import SinglePublication from "@components/Publication/SinglePublication";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import QueuedPost from "@components/Publication/QueuedPost";
import SinglePost from "@components/Publication/SinglePost";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import { LightBulbIcon } from "@heroicons/react/24/outline";
import type { AnyPublication, PublicationForYouRequest } from "@hey/lens";
import { LimitType, useForYouQuery } from "@hey/lens";
Expand Down Expand Up @@ -49,7 +49,7 @@ const ForYou: FC = () => {
};

if (loading) {
return <PublicationsShimmer />;
return <PostsShimmer />;
}

if (publications?.length === 0) {
Expand All @@ -69,7 +69,7 @@ const ForYou: FC = () => {
<>
{txnQueue.map((txn) =>
txn?.type === OptmisticPublicationType.Post ? (
<QueuedPublication key={txn.txId} txn={txn} />
<QueuedPost key={txn.txId} txn={txn} />
) : null
)}
<Card>
Expand All @@ -79,7 +79,7 @@ const ForYou: FC = () => {
data={publications}
endReached={onEndReached}
itemContent={(index, item) => (
<SinglePublication
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={item.publication as AnyPublication}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Home/PaidActions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SinglePublication from "@components/Publication/SinglePublication";
import SinglePost from "@components/Publication/SinglePost";
import PaidActionsShimmer from "@components/Shared/Shimmer/PaidActionsShimmer";
import { CurrencyDollarIcon } from "@heroicons/react/24/outline";
import type { AnyPublication, LatestActed, PaginatedRequest } from "@hey/lens";
Expand Down Expand Up @@ -63,7 +63,7 @@ const PaidActions: FC = () => {
publication={action.actedOn as AnyPublication}
/>
<div className="divider" />
<SinglePublication
<SinglePost
isFirst={false}
isLast
publication={action.actedOn as AnyPublication}
Expand Down
12 changes: 6 additions & 6 deletions apps/web/src/components/Home/Timeline/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QueuedPublication from "@components/Publication/QueuedPublication";
import SinglePublication from "@components/Publication/SinglePublication";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import QueuedPost from "@components/Publication/QueuedPost";
import SinglePost from "@components/Publication/SinglePost";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import { UserGroupIcon } from "@heroicons/react/24/outline";
import { HEY_CURATED_ID } from "@hey/data/constants";
import type { AnyPublication, FeedItem, FeedRequest } from "@hey/lens";
Expand Down Expand Up @@ -78,7 +78,7 @@ const Timeline: FC = () => {
};

if (loading) {
return <PublicationsShimmer />;
return <PostsShimmer />;
}

if (feed?.length === 0) {
Expand All @@ -98,7 +98,7 @@ const Timeline: FC = () => {
<>
{txnQueue.map((txn) =>
txn?.type !== OptmisticPublicationType.Comment ? (
<QueuedPublication key={txn.txId} txn={txn} />
<QueuedPost key={txn.txId} txn={txn} />
) : null
)}
<Card>
Expand All @@ -109,7 +109,7 @@ const Timeline: FC = () => {
endReached={onEndReached}
isScrolling={onScrolling}
itemContent={(index, feedItem) => (
<SinglePublication
<SinglePost
feedItem={feedItem as FeedItem}
isFirst={index === 0}
isLast={index === (feed?.length || 0) - 1}
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/List/ListFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SinglePublication from "@components/Publication/SinglePublication";
import SinglePost from "@components/Publication/SinglePost";
import PinUnpinButton from "@components/Shared/List/PinUnpinButton";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import SingleList from "@components/Shared/SingleList";
import { ChatBubbleBottomCenterIcon } from "@heroicons/react/24/outline";
import { HEY_API_URL } from "@hey/data/constants";
Expand Down Expand Up @@ -88,7 +88,7 @@ const ListFeed: FC<ListFeedProps> = ({ list, showHeader = false }) => {
};

if (loadingPublicationIds || publicationsLoading) {
return <PublicationsShimmer />;
return <PostsShimmer />;
}

const Header = () => {
Expand Down Expand Up @@ -141,7 +141,7 @@ const ListFeed: FC<ListFeedProps> = ({ list, showHeader = false }) => {
data={publications}
isScrolling={onScrolling}
itemContent={(index, publication) => (
<SinglePublication
<SinglePost
isFirst={index === 0}
isLast={index === (publications?.length || 0) - 1}
publication={publication as AnyPublication}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/List/Shimmer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Footer from "@components/Shared/Footer";
import PostsShimmer from "@components/Shared/Shimmer/PostsShimmer";
import ProfileListShimmer from "@components/Shared/Shimmer/ProfileListShimmer";
import PublicationsShimmer from "@components/Shared/Shimmer/PublicationsShimmer";
import { Card, GridItemEight, GridItemFour, GridLayout } from "@hey/ui";
import type { FC } from "react";

Expand All @@ -17,7 +17,7 @@ const ListPageShimmer: FC<ClubPageShimmerProps> = ({ profileList = false }) => {
<ProfileListShimmer />
</Card>
) : (
<PublicationsShimmer />
<PostsShimmer />
)}
</GridItemEight>
<GridItemFour>
Expand Down
Loading

1 comment on commit 8e451b9

@vercel
Copy link

@vercel vercel bot commented on 8e451b9 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 – ./

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

Please sign in to comment.