From 124530734e64a00427c174868db1bb979178b596 Mon Sep 17 00:00:00 2001 From: Yoginth Date: Wed, 13 Nov 2024 17:52:37 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8D=20Rename=20publication=20to=20post?= =?UTF-8?q?=20for=20v3=20preparation:=20v4=20(#pre-lens-v3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Renamed `publication` to `post` across components for v3 preparation. Highlights: • Updated interfaces and props from `publication` to `post` in multiple components. • Adjusted function and variable names to reflect the change from `publication` to `post`. • Modified store state and actions to use `post` instead of `publication`. Read more: https://pierre.co/hey/hey/pre-lens-v3 --- .../src/components/Composer/LinkPreviews.tsx | 4 +- .../components/Composer/NewPublication.tsx | 43 +++++++++---------- .../Home/PaidActions/OpenActionPaidAction.tsx | 6 +-- .../src/components/Home/PaidActions/index.tsx | 2 +- .../Home/Sidebar/HeyMembershipNft/Mint.tsx | 6 +-- apps/web/src/components/Mod/LatestFeed.tsx | 2 +- .../Mod/ReportsFeed/ReportDetails.tsx | 2 +- apps/web/src/components/Mod/SearchFeed.tsx | 2 +- .../Actions/HigherActions/GardenerActions.tsx | 12 +++--- .../Actions/HigherActions/StaffActions.tsx | 10 ++--- .../Actions/HigherActions/index.tsx | 6 +-- .../Publication/Actions/Menu/Bookmark.tsx | 22 +++++----- .../Publication/Actions/Menu/CopyPostText.tsx | 14 +++--- .../Publication/Actions/Menu/Delete.tsx | 8 ++-- .../Publication/Actions/Menu/HideComment.tsx | 14 +++--- .../Actions/Menu/NotInterested.tsx | 14 +++--- .../Publication/Actions/Menu/Report.tsx | 6 +-- .../Publication/Actions/Menu/Share.tsx | 8 ++-- .../Publication/Actions/Menu/index.tsx | 26 +++++------ .../Publication/Actions/Share/Quote.tsx | 4 +- .../src/components/Publication/FullPost.tsx | 19 ++++---- .../CollectModule/CollectAction.tsx | 23 +++++----- .../OpenAction/CollectModule/index.tsx | 2 +- .../src/components/Publication/PostAvatar.tsx | 8 ++-- .../src/components/Publication/PostHeader.tsx | 18 ++++---- .../src/components/Publication/QuotedPost.tsx | 4 +- .../src/components/Publication/SinglePost.tsx | 12 ++---- .../src/components/Publication/ThreadBody.tsx | 20 ++++----- .../src/components/Publication/Translate.tsx | 8 ++-- .../components/Publication/Type/Commented.tsx | 4 +- .../src/components/Publication/Type/index.tsx | 16 +++---- apps/web/src/components/Publication/index.tsx | 17 ++++---- .../Shared/Alert/DeletePublication.tsx | 17 +++----- .../src/components/Shared/GlobalAlerts.tsx | 6 +-- .../src/components/StaffTools/Panels/Post.tsx | 18 ++++---- .../publication/usePublicationStore.ts | 9 ++-- .../non-persisted/useGlobalAlertStateStore.ts | 31 ++++++------- 37 files changed, 209 insertions(+), 234 deletions(-) diff --git a/apps/web/src/components/Composer/LinkPreviews.tsx b/apps/web/src/components/Composer/LinkPreviews.tsx index 3b597493373a..954a6f3981bd 100644 --- a/apps/web/src/components/Composer/LinkPreviews.tsx +++ b/apps/web/src/components/Composer/LinkPreviews.tsx @@ -10,7 +10,7 @@ import { usePublicationAttributesStore } from "src/store/non-persisted/publicati import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore"; const LinkPreviews: FC = () => { - const { publicationContent, quotedPublication } = usePublicationStore(); + const { publicationContent, quotedPost } = usePublicationStore(); const { attachments } = usePublicationAttachmentStore((state) => state); const { addAttribute, getAttribute, removeAttribute } = usePublicationAttributesStore(); @@ -27,7 +27,7 @@ const LinkPreviews: FC = () => { if ( !urls.length || attachments.length || - quotedPublication || + quotedPost || getAttribute(KNOWN_ATTRIBUTES.HIDE_OEMBED)?.value === "true" ) { return null; diff --git a/apps/web/src/components/Composer/NewPublication.tsx b/apps/web/src/components/Composer/NewPublication.tsx index 037da3b52f5c..6d8f51193780 100644 --- a/apps/web/src/components/Composer/NewPublication.tsx +++ b/apps/web/src/components/Composer/NewPublication.tsx @@ -91,13 +91,10 @@ const LivestreamSettings = dynamic( interface NewPublicationProps { className?: string; - publication?: MirrorablePublication; + post?: MirrorablePublication; } -const NewPublication: FC = ({ - className, - publication -}) => { +const NewPublication: FC = ({ className, post }) => { const { currentProfile } = useProfileStore(); const { isSuspended } = useProfileStatus(); @@ -110,9 +107,9 @@ const NewPublication: FC = ({ // Publication store const { publicationContent, - quotedPublication, + quotedPost, setPublicationContent, - setQuotedPublication, + setQuotedPost, setTags } = usePublicationStore(); @@ -161,17 +158,17 @@ const NewPublication: FC = ({ const { canUseLensManager } = checkDispatcherPermissions(currentProfile); - const isComment = Boolean(publication); - const isQuote = Boolean(quotedPublication); + const isComment = Boolean(post); + const isQuote = Boolean(quotedPost); const hasAudio = attachments[0]?.type === "Audio"; const hasVideo = attachments[0]?.type === "Video"; const noCollect = !collectModule.type; // Use Momoka if the profile the comment or quote has momoka proof and also check collect module has been disabled const useMomoka = isComment - ? publication?.momoka?.proof + ? post?.momoka?.proof : isQuote - ? quotedPublication?.momoka?.proof + ? quotedPost?.momoka?.proof : noCollect; const reset = () => { @@ -184,7 +181,7 @@ const NewPublication: FC = ({ setShowLiveVideoEditor(false); resetLiveVideoConfig(); setAttachments([]); - setQuotedPublication(null); + setQuotedPost(null); setVideoThumbnail(DEFAULT_VIDEO_THUMBNAIL); setAudioPublication(DEFAULT_AUDIO_PUBLICATION); setLicense(null); @@ -217,7 +214,7 @@ const NewPublication: FC = ({ // Track in leafwatch const eventProperties = { - comment_on: isComment ? publication?.id : null, + comment_on: isComment ? post?.id : null, publication_collect_module: collectModule.type, publication_has_attachments: attachments.length > 0, publication_has_poll: showPollEditor, @@ -228,7 +225,7 @@ const NewPublication: FC = ({ ReferenceModuleType.DegreesOfSeparationReferenceModule ? degreesOfSeparation : null, - quote_on: isQuote ? quotedPublication?.id : null + quote_on: isQuote ? quotedPost?.id : null }; Leafwatch.track( isComment @@ -255,10 +252,10 @@ const NewPublication: FC = ({ createQuoteOnMomka, error } = useCreatePublication({ - commentOn: publication, + commentOn: post, onCompleted, onError, - quoteOn: quotedPublication as Quote + quoteOn: quotedPost as Quote }); useEffect(() => { @@ -379,8 +376,8 @@ const NewPublication: FC = ({ | MomokaCommentRequest | MomokaPostRequest | MomokaQuoteRequest = { - ...(isComment && { commentOn: publication?.id }), - ...(isQuote && { quoteOn: quotedPublication?.id }), + ...(isComment && { commentOn: post?.id }), + ...(isQuote && { quoteOn: quotedPost?.id }), contentURI: `${METADATA_ENDPOINT}/${metadataId}` }; @@ -424,8 +421,8 @@ const NewPublication: FC = ({ | OnchainPostRequest | OnchainQuoteRequest = { contentURI: `${METADATA_ENDPOINT}/${metadataId}`, - ...(isComment && { commentOn: publication?.id }), - ...(isQuote && { quoteOn: quotedPublication?.id }), + ...(isComment && { commentOn: post?.id }), + ...(isQuote && { quoteOn: quotedPost?.id }), openActionModules, ...(onlyFollowers && { referenceModule: @@ -522,9 +519,9 @@ const NewPublication: FC = ({ {showLiveVideoEditor ? : null} - {quotedPublication ? ( + {quotedPost ? ( - + ) : null}
@@ -540,7 +537,7 @@ const NewPublication: FC = ({ showEmojiPicker={showEmojiPicker} /> setGifAttachment(gif)} /> - {publication?.momoka?.proof ? null : ( + {post?.momoka?.proof ? null : ( <> diff --git a/apps/web/src/components/Home/PaidActions/OpenActionPaidAction.tsx b/apps/web/src/components/Home/PaidActions/OpenActionPaidAction.tsx index c5908c183dae..072c0301f0ea 100644 --- a/apps/web/src/components/Home/PaidActions/OpenActionPaidAction.tsx +++ b/apps/web/src/components/Home/PaidActions/OpenActionPaidAction.tsx @@ -12,14 +12,14 @@ import type { FC } from "react"; interface OpenActionPaidActionProps { latestActed: LatestActed[]; - publication: AnyPublication; + post: AnyPublication; } const OpenActionPaidAction: FC = ({ latestActed, - publication + post }) => { - const targetPost = isRepost(publication) ? publication.mirrorOn : publication; + const targetPost = isRepost(post) ? post.mirrorOn : post; const openActions = targetPost.openActionModules .filter( diff --git a/apps/web/src/components/Home/PaidActions/index.tsx b/apps/web/src/components/Home/PaidActions/index.tsx index 0c78873440d1..bdb315b586cc 100644 --- a/apps/web/src/components/Home/PaidActions/index.tsx +++ b/apps/web/src/components/Home/PaidActions/index.tsx @@ -60,7 +60,7 @@ const PaidActions: FC = () => {
= ({ onCollectSuccess }) => { ); } - const publication = data?.publication as Post; - const openAction = publication.openActionModules[0]; + const post = data?.publication as Post; + const openAction = post.openActionModules[0]; return (
@@ -92,7 +92,7 @@ const Mint: FC = ({ onCollectSuccess }) => { } onCollectSuccess={onCollectSuccess} openAction={openAction} - publication={publication} + post={post} />
diff --git a/apps/web/src/components/Mod/LatestFeed.tsx b/apps/web/src/components/Mod/LatestFeed.tsx index 59434ff22002..6a881609b48c 100644 --- a/apps/web/src/components/Mod/LatestFeed.tsx +++ b/apps/web/src/components/Mod/LatestFeed.tsx @@ -102,7 +102,7 @@ const LatestFeed: FC = () => { showThread={false} />
- + )} useWindowScroll diff --git a/apps/web/src/components/Mod/ReportsFeed/ReportDetails.tsx b/apps/web/src/components/Mod/ReportsFeed/ReportDetails.tsx index 037e18744531..28c25d6e10c7 100644 --- a/apps/web/src/components/Mod/ReportsFeed/ReportDetails.tsx +++ b/apps/web/src/components/Mod/ReportsFeed/ReportDetails.tsx @@ -79,7 +79,7 @@ const ReportDetails: FC = ({
diff --git a/apps/web/src/components/Mod/SearchFeed.tsx b/apps/web/src/components/Mod/SearchFeed.tsx index fd4d628dcc65..6020d3e2e5b6 100644 --- a/apps/web/src/components/Mod/SearchFeed.tsx +++ b/apps/web/src/components/Mod/SearchFeed.tsx @@ -110,7 +110,7 @@ const SearchFeed: FC = () => { showThread={false} />
- + ); }} diff --git a/apps/web/src/components/Publication/Actions/HigherActions/GardenerActions.tsx b/apps/web/src/components/Publication/Actions/HigherActions/GardenerActions.tsx index ae99266107db..be86e0b5f21c 100644 --- a/apps/web/src/components/Publication/Actions/HigherActions/GardenerActions.tsx +++ b/apps/web/src/components/Publication/Actions/HigherActions/GardenerActions.tsx @@ -16,10 +16,10 @@ import { useGlobalAlertStateStore } from "src/store/non-persisted/useGlobalAlert import StaffActions from "./StaffActions"; interface GardenerActionsProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const GardenerActions: FC = ({ publication }) => { +const GardenerActions: FC = ({ post }) => { const { pathname } = useRouter(); const { setShowGardenerActionsAlert } = useGlobalAlertStateStore(); const [loading, setLoading] = useState(false); @@ -29,14 +29,14 @@ const GardenerActions: FC = ({ publication }) => { subreasons: PublicationReportingSpamSubreason[] ) => { if (pathname === "/mod") { - cache.evict({ id: cache.identify(publication) }); + cache.evict({ id: cache.identify(post) }); } setLoading(true); try { await axios.post( `${HEY_API_URL}/internal/gardener/report`, - { id: publication.id, subreasons }, + { id: post.id, subreasons }, { headers: getAuthApiHeadersWithAccessToken() } ); } finally { @@ -53,7 +53,7 @@ const GardenerActions: FC = ({ publication }) => { type: string; }) => { Leafwatch.track(GARDENER.REPORT, { - publication_id: publication.id, + publication_id: post.id, type }); toast.promise(reportPublicationOnLens(subreasons), { @@ -125,7 +125,7 @@ const GardenerActions: FC = ({ publication }) => { type: "suspend" }); }} - publication={publication} + post={post} />
diff --git a/apps/web/src/components/Publication/Actions/HigherActions/StaffActions.tsx b/apps/web/src/components/Publication/Actions/HigherActions/StaffActions.tsx index 05f2d9007d5d..bb1a3d598436 100644 --- a/apps/web/src/components/Publication/Actions/HigherActions/StaffActions.tsx +++ b/apps/web/src/components/Publication/Actions/HigherActions/StaffActions.tsx @@ -16,15 +16,15 @@ import { toast } from "react-hot-toast"; interface StaffActionsProps { onClick?: () => void; - publication: MirrorablePublication; + post: MirrorablePublication; } -const StaffActions: FC = ({ onClick, publication }) => { +const StaffActions: FC = ({ onClick, post }) => { const isStaff = useFlag(FeatureFlag.Staff); const { data: profile } = useQuery({ - queryFn: () => getInternalProfile(publication.by.id, getAuthApiHeaders()), - queryKey: [GET_INTERNAL_PROFILE_QUERY_KEY, publication.by.id || ""], + queryFn: () => getInternalProfile(post.by.id, getAuthApiHeaders()), + queryKey: [GET_INTERNAL_PROFILE_QUERY_KEY, post.by.id || ""], enabled: isStaff }); @@ -37,7 +37,7 @@ const StaffActions: FC = ({ onClick, publication }) => { toast.promise( axios.post( `${HEY_API_URL}/internal/permissions/assign`, - { enabled: true, id, profile_id: publication.by.id }, + { enabled: true, id, profile_id: post.by.id }, { headers: getAuthApiHeaders() } ), { diff --git a/apps/web/src/components/Publication/Actions/HigherActions/index.tsx b/apps/web/src/components/Publication/Actions/HigherActions/index.tsx index 2b947cca5c71..69ba7957d28d 100644 --- a/apps/web/src/components/Publication/Actions/HigherActions/index.tsx +++ b/apps/web/src/components/Publication/Actions/HigherActions/index.tsx @@ -3,13 +3,13 @@ import type { FC } from "react"; import GardenerActions from "./GardenerActions"; interface HigherActionsProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const HigherActions: FC = ({ publication }) => { +const HigherActions: FC = ({ post }) => { return (
- +
); }; diff --git a/apps/web/src/components/Publication/Actions/Menu/Bookmark.tsx b/apps/web/src/components/Publication/Actions/Menu/Bookmark.tsx index 5ce804631424..735df85bcad4 100644 --- a/apps/web/src/components/Publication/Actions/Menu/Bookmark.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/Bookmark.tsx @@ -21,16 +21,16 @@ import type { FC } from "react"; import { toast } from "react-hot-toast"; interface BookmarkProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const Bookmark: FC = ({ publication }) => { +const Bookmark: FC = ({ post }) => { const { pathname } = useRouter(); const [hasBookmarked, toggleHasBookmarked] = useToggle( - publication.operations.hasBookmarked + post.operations.hasBookmarked ); const [bookmarks, { decrement, increment }] = useCounter( - publication.stats.bookmarks + post.stats.bookmarks ); const updateCache = (cache: ApolloCache) => { @@ -40,18 +40,18 @@ const Bookmark: FC = ({ publication }) => { return { ...existingValue, hasBookmarked: !hasBookmarked }; } }, - id: cache.identify(publication) + id: cache.identify(post) }); cache.modify({ fields: { bookmarks: () => (hasBookmarked ? bookmarks - 1 : bookmarks + 1) }, - id: cache.identify(publication.stats) + id: cache.identify(post.stats) }); - // Remove bookmarked publication from bookmarks feed + // Remove bookmarked post from bookmarks feed if (pathname === "/bookmarks") { - cache.evict({ id: cache.identify(publication) }); + cache.evict({ id: cache.identify(post) }); } }; @@ -59,13 +59,13 @@ const Bookmark: FC = ({ publication }) => { errorToast(error); }; - const request: PublicationBookmarkRequest = { on: publication.id }; + const request: PublicationBookmarkRequest = { on: post.id }; const [addPublicationBookmark] = useAddPublicationBookmarkMutation({ onCompleted: () => { toast.success("Publication bookmarked!"); Leafwatch.track(PUBLICATION.BOOKMARK, { - publication_id: publication.id + publication_id: post.id }); }, onError: (error) => { @@ -81,7 +81,7 @@ const Bookmark: FC = ({ publication }) => { onCompleted: () => { toast.success("Removed publication bookmark!"); Leafwatch.track(PUBLICATION.REMOVE_BOOKMARK, { - publication_id: publication.id + publication_id: post.id }); }, onError: (error) => { diff --git a/apps/web/src/components/Publication/Actions/Menu/CopyPostText.tsx b/apps/web/src/components/Publication/Actions/Menu/CopyPostText.tsx index ef4a47492d8b..d42a04e8b51f 100644 --- a/apps/web/src/components/Publication/Actions/Menu/CopyPostText.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/CopyPostText.tsx @@ -10,12 +10,12 @@ import type { FC } from "react"; import toast from "react-hot-toast"; interface CopyPostTextProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const CopyPostText: FC = ({ publication }) => { - const publicationType = publication.__typename; - const filteredContent = getPostData(publication.metadata)?.content || ""; +const CopyPostText: FC = ({ post }) => { + const postType = post.__typename; + const filteredContent = getPostData(post.metadata)?.content || ""; return ( = ({ publication }) => { await navigator.clipboard.writeText(filteredContent || ""); toast.success("Content copied to clipboard!"); Leafwatch.track(PUBLICATION.COPY_TEXT, { - publication_id: publication.id + publication_id: post.id }); }} >
- {publicationType === "Comment" - ? "Copy comment text" - : "Copy post text"} + {postType === "Comment" ? "Copy comment text" : "Copy post text"}
diff --git a/apps/web/src/components/Publication/Actions/Menu/Delete.tsx b/apps/web/src/components/Publication/Actions/Menu/Delete.tsx index 280299e74efd..33f7795d5523 100644 --- a/apps/web/src/components/Publication/Actions/Menu/Delete.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/Delete.tsx @@ -7,11 +7,11 @@ import type { FC } from "react"; import { useGlobalAlertStateStore } from "src/store/non-persisted/useGlobalAlertStateStore"; interface DeleteProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const Delete: FC = ({ publication }) => { - const { setShowPublicationDeleteAlert } = useGlobalAlertStateStore(); +const Delete: FC = ({ post }) => { + const { setShowPostDeleteAlert } = useGlobalAlertStateStore(); return ( = ({ publication }) => { } onClick={(event) => { stopEventPropagation(event); - setShowPublicationDeleteAlert(true, publication); + setShowPostDeleteAlert(true, post); }} >
diff --git a/apps/web/src/components/Publication/Actions/Menu/HideComment.tsx b/apps/web/src/components/Publication/Actions/Menu/HideComment.tsx index ca431dcbe4fb..174b17a1a8a8 100644 --- a/apps/web/src/components/Publication/Actions/Menu/HideComment.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/HideComment.tsx @@ -18,19 +18,19 @@ import { toast } from "react-hot-toast"; import { useProfileStore } from "src/store/persisted/useProfileStore"; interface HideCommentProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const HideComment: FC = ({ publication }) => { +const HideComment: FC = ({ post }) => { const { currentProfile } = useProfileStore(); const { showHiddenComments } = useHiddenCommentFeedStore(); const request: HideCommentRequest | UnhideCommentRequest = { - for: publication.id + for: post.id }; const updateCache = (cache: ApolloCache) => { - cache.evict({ id: cache.identify(publication) }); + cache.evict({ id: cache.identify(post) }); }; const onError = (error: any) => { @@ -42,7 +42,7 @@ const HideComment: FC = ({ publication }) => { toast.success("Comment hidden"); Leafwatch.track(PUBLICATION.TOGGLE_HIDE_COMMENT, { hidden: true, - publication_id: publication.id + publication_id: post.id }); }, onError, @@ -55,7 +55,7 @@ const HideComment: FC = ({ publication }) => { toast.success("Comment unhidden"); Leafwatch.track(PUBLICATION.TOGGLE_HIDE_COMMENT, { hidden: false, - publication_id: publication.id + publication_id: post.id }); }, onError, @@ -63,7 +63,7 @@ const HideComment: FC = ({ publication }) => { variables: { request } }); - const canHideComment = currentProfile?.id !== publication?.by?.id; + const canHideComment = currentProfile?.id !== post?.by?.id; if (!canHideComment) { return null; diff --git a/apps/web/src/components/Publication/Actions/Menu/NotInterested.tsx b/apps/web/src/components/Publication/Actions/Menu/NotInterested.tsx index 02e1e4d43c40..4773254da6a1 100644 --- a/apps/web/src/components/Publication/Actions/Menu/NotInterested.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/NotInterested.tsx @@ -18,14 +18,14 @@ import type { FC } from "react"; import { toast } from "react-hot-toast"; interface NotInterestedProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const NotInterested: FC = ({ publication }) => { - const notInterested = publication.operations.isNotInterested; +const NotInterested: FC = ({ post }) => { + const notInterested = post.operations.isNotInterested; const request: PublicationNotInterestedRequest = { - on: publication.id + on: post.id }; const updateCache = (cache: ApolloCache, notInterested: boolean) => { @@ -35,7 +35,7 @@ const NotInterested: FC = ({ publication }) => { return { ...existingValue, isNotInterested: notInterested }; } }, - id: cache.identify(publication) + id: cache.identify(post) }); }; @@ -47,7 +47,7 @@ const NotInterested: FC = ({ publication }) => { onCompleted: () => { toast.success("Marked as not Interested"); Leafwatch.track(PUBLICATION.NOT_INTERESTED, { - publication_id: publication.id + publication_id: post.id }); }, onError, @@ -60,7 +60,7 @@ const NotInterested: FC = ({ publication }) => { onCompleted: () => { toast.success("Undo Not interested"); Leafwatch.track(PUBLICATION.UNDO_NOT_INTERESTED, { - publication_id: publication.id + publication_id: post.id }); }, onError, diff --git a/apps/web/src/components/Publication/Actions/Menu/Report.tsx b/apps/web/src/components/Publication/Actions/Menu/Report.tsx index b86ba986135b..48dfd91b981c 100644 --- a/apps/web/src/components/Publication/Actions/Menu/Report.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/Report.tsx @@ -7,10 +7,10 @@ import type { FC } from "react"; import { useGlobalModalStateStore } from "src/store/non-persisted/useGlobalModalStateStore"; interface ReportProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const Report: FC = ({ publication }) => { +const Report: FC = ({ post }) => { const { setShowPublicationReportModal } = useGlobalModalStateStore(); return ( @@ -24,7 +24,7 @@ const Report: FC = ({ publication }) => { } onClick={(event) => { stopEventPropagation(event); - setShowPublicationReportModal(true, publication.id); + setShowPublicationReportModal(true, post.id); }} >
diff --git a/apps/web/src/components/Publication/Actions/Menu/Share.tsx b/apps/web/src/components/Publication/Actions/Menu/Share.tsx index 7ab4f89ea932..9701fe9c767d 100644 --- a/apps/web/src/components/Publication/Actions/Menu/Share.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/Share.tsx @@ -9,10 +9,10 @@ import type { FC } from "react"; import toast from "react-hot-toast"; interface ShareProps { - publication: MirrorablePublication; + post: MirrorablePublication; } -const Share: FC = ({ publication }) => { +const Share: FC = ({ post }) => { return ( = ({ publication }) => { onClick={async (event) => { stopEventPropagation(event); await navigator.clipboard.writeText( - `${location.origin}/posts/${publication?.id}` + `${location.origin}/posts/${post?.id}` ); toast.success("Copied to clipboard!"); - Leafwatch.track(PUBLICATION.SHARE, { publication_id: publication.id }); + Leafwatch.track(PUBLICATION.SHARE, { publication_id: post.id }); }} >
diff --git a/apps/web/src/components/Publication/Actions/Menu/index.tsx b/apps/web/src/components/Publication/Actions/Menu/index.tsx index c981c70674f3..5cf0829b4796 100644 --- a/apps/web/src/components/Publication/Actions/Menu/index.tsx +++ b/apps/web/src/components/Publication/Actions/Menu/index.tsx @@ -16,11 +16,11 @@ import NotInterested from "./NotInterested"; import Report from "./Report"; import Share from "./Share"; -interface PublicationMenuProps { - publication: MirrorablePublication; +interface PostMenuProps { + post: MirrorablePublication; } -const PublicationMenu: FC = ({ publication }) => { +const PostMenu: FC = ({ post }) => { const { currentProfile } = useProfileStore(); const iconClassName = "w-[15px] sm:w-[18px]"; @@ -45,20 +45,20 @@ const PublicationMenu: FC = ({ publication }) => { > {currentProfile ? ( <> - - - + + + ) : null}
- - - + + +
- {currentProfile?.id === publication?.by?.id ? ( - + {currentProfile?.id === post?.by?.id ? ( + ) : ( - + )} @@ -66,4 +66,4 @@ const PublicationMenu: FC = ({ publication }) => { ); }; -export default PublicationMenu; +export default PostMenu; diff --git a/apps/web/src/components/Publication/Actions/Share/Quote.tsx b/apps/web/src/components/Publication/Actions/Share/Quote.tsx index ac04f92352c5..9f4f1f602d8d 100644 --- a/apps/web/src/components/Publication/Actions/Share/Quote.tsx +++ b/apps/web/src/components/Publication/Actions/Share/Quote.tsx @@ -18,7 +18,7 @@ interface QuoteProps { const Quote: FC = ({ publication }) => { const { currentProfile } = useProfileStore(); const { setShowAuthModal, setShowNewPostModal } = useGlobalModalStateStore(); - const { setQuotedPublication } = usePublicationStore(); + const { setQuotedPost } = usePublicationStore(); const { isSuspended } = useProfileStatus(); const publicationType = publication.__typename; @@ -45,7 +45,7 @@ const Quote: FC = ({ publication }) => { return toast.error(Errors.Suspended); } - setQuotedPublication(publication); + setQuotedPost(publication); setShowNewPostModal(true); }} > diff --git a/apps/web/src/components/Publication/FullPost.tsx b/apps/web/src/components/Publication/FullPost.tsx index 36a5ba806db0..5d857da2784f 100644 --- a/apps/web/src/components/Publication/FullPost.tsx +++ b/apps/web/src/components/Publication/FullPost.tsx @@ -21,22 +21,19 @@ import PostBody from "./PostBody"; import PostHeader from "./PostHeader"; import PostStats from "./PostStats"; import Translate from "./Translate"; -import PublicationType from "./Type"; +import PostType from "./Type"; interface FullPostProps { hasHiddenComments: boolean; - publication: AnyPublication; + post: AnyPublication; } -const FullPost: FC = ({ hasHiddenComments, publication }) => { +const FullPost: FC = ({ hasHiddenComments, post }) => { const { setShowHiddenComments, showHiddenComments } = useHiddenCommentFeedStore(); const isStaff = useFlag(FeatureFlag.Staff); - const targetPost = isRepost(publication) - ? publication?.mirrorOn - : publication; - + const targetPost = isRepost(post) ? post?.mirrorOn : post; const { by, createdAt, publishedOn } = targetPost; usePushToImpressions(targetPost.id); @@ -61,11 +58,11 @@ const FullPost: FC = ({ hasHiddenComments, publication }) => { return (
- +
- +
- + {targetPost.isHidden ? ( ) : ( @@ -74,7 +71,7 @@ const FullPost: FC = ({ hasHiddenComments, publication }) => { contentClassName="full-page-publication-markup" post={targetPost} /> - +
{formatDate(createdAt, "hh:mm A · MMM D, YYYY")} {publishedOn?.id ? ( diff --git a/apps/web/src/components/Publication/OpenAction/CollectModule/CollectAction.tsx b/apps/web/src/components/Publication/OpenAction/CollectModule/CollectAction.tsx index dd7f79883b96..f3c93b23c0f0 100644 --- a/apps/web/src/components/Publication/OpenAction/CollectModule/CollectAction.tsx +++ b/apps/web/src/components/Publication/OpenAction/CollectModule/CollectAction.tsx @@ -55,7 +55,7 @@ interface CollectActionProps { noBalanceErrorMessages?: ReactNode; onCollectSuccess?: () => void; openAction: OpenActionModule; - publication: MirrorablePublication; + post: MirrorablePublication; } const CollectAction: FC = ({ @@ -66,7 +66,7 @@ const CollectAction: FC = ({ noBalanceErrorMessages, onCollectSuccess = () => {}, openAction, - publication + post }) => { const collectModule = getCollectModuleData(openAction as any); @@ -86,8 +86,7 @@ const CollectAction: FC = ({ const [hasActed, setHasActed] = useState( collectModule?.amount ? false - : publication.operations.hasActed.value || - hasOptimisticallyCollected(publication.id) + : post.operations.hasActed.value || hasOptimisticallyCollected(post.id) ); const { address } = useAccount(); @@ -114,10 +113,10 @@ const CollectAction: FC = ({ openAction.__typename === "SimpleCollectOpenActionSettings"; const isFollowersOnly = collectModule?.followerOnly; const isFollowedByMe = isFollowersOnly - ? publication?.by.operations.isFollowedByMe.value + ? post?.by.operations.isFollowedByMe.value : true; const isFollowFinalizedOnchain = isFollowersOnly - ? !isFollowPending(publication.by.id) + ? !isFollowPending(post.by.id) : true; const canUseManager = @@ -134,7 +133,7 @@ const CollectAction: FC = ({ txId?: string; }): OptimisticTransaction => { return { - collectOn: publication?.id, + collectOn: post?.id, txHash, txId, type: OptmisticPublicationType.Collect @@ -148,11 +147,11 @@ const CollectAction: FC = ({ return { ...existingValue, hasActed: { value: true } }; } }, - id: cache.identify(publication) + id: cache.identify(post) }); cache.modify({ fields: { countOpenActions: () => countOpenActions + 1 }, - id: cache.identify(publication.stats) + id: cache.identify(post.stats) }); }; @@ -180,7 +179,7 @@ const CollectAction: FC = ({ Leafwatch.track(PUBLICATION.COLLECT_MODULE.COLLECT, { amount, collect_module: openAction?.type, - publication_id: publication?.id + publication_id: post?.id }); }; @@ -320,7 +319,7 @@ const CollectAction: FC = ({ setIsLoading(true); const actOnRequest: ActOnOpenActionLensManagerRequest = { actOn: { [getOpenActionActOnKey(openAction.type)]: true }, - for: publication?.id + for: post?.id }; if (canUseManager) { @@ -401,7 +400,7 @@ const CollectAction: FC = ({ ); } diff --git a/apps/web/src/components/Publication/OpenAction/CollectModule/index.tsx b/apps/web/src/components/Publication/OpenAction/CollectModule/index.tsx index a1479258224e..b1b4ae3cec12 100644 --- a/apps/web/src/components/Publication/OpenAction/CollectModule/index.tsx +++ b/apps/web/src/components/Publication/OpenAction/CollectModule/index.tsx @@ -266,7 +266,7 @@ const CollectModule: FC = ({ openAction, post }) => { countOpenActions={countOpenActions} onCollectSuccess={() => increment()} openAction={openAction} - publication={targetPost} + post={targetPost} />
diff --git a/apps/web/src/components/Publication/PostAvatar.tsx b/apps/web/src/components/Publication/PostAvatar.tsx index dd1c1ed33443..1e1262727a20 100644 --- a/apps/web/src/components/Publication/PostAvatar.tsx +++ b/apps/web/src/components/Publication/PostAvatar.tsx @@ -13,19 +13,17 @@ import { memo } from "react"; interface PostAvatarProps { feedItem?: FeedItem; - publication: AnyPublication; + post: AnyPublication; quoted?: boolean; } const PostAvatar: FC = ({ feedItem, - publication, + post, quoted = false }) => { const { push } = useRouter(); - const targetPost = isRepost(publication) - ? publication?.mirrorOn - : publication; + const targetPost = isRepost(post) ? post?.mirrorOn : post; const rootPublication = feedItem ? feedItem?.root : targetPost; const profile = feedItem ? rootPublication.by : targetPost.by; diff --git a/apps/web/src/components/Publication/PostHeader.tsx b/apps/web/src/components/Publication/PostHeader.tsx index 12716c461ce4..d6d22bc4256e 100644 --- a/apps/web/src/components/Publication/PostHeader.tsx +++ b/apps/web/src/components/Publication/PostHeader.tsx @@ -5,26 +5,24 @@ import stopEventPropagation from "@hey/helpers/stopEventPropagation"; import type { AnyPublication, FeedItem } from "@hey/lens"; import type { FC } from "react"; import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore"; -import PublicationMenu from "./Actions/Menu"; +import PostMenu from "./Actions/Menu"; interface PostHeaderProps { feedItem?: FeedItem; isNew?: boolean; - publication: AnyPublication; + post: AnyPublication; quoted?: boolean; } const PostHeader: FC = ({ feedItem, isNew = false, - publication, + post, quoted = false }) => { - const { setQuotedPublication } = usePublicationStore(); + const { setQuotedPost } = usePublicationStore(); - const targetPost = isRepost(publication) - ? publication?.mirrorOn - : publication; + const targetPost = isRepost(post) ? post?.mirrorOn : post; const rootPublication = feedItem ? feedItem?.root : targetPost; const profile = feedItem ? rootPublication.by : targetPost.by; const timestamp = feedItem ? rootPublication.createdAt : targetPost.createdAt; @@ -41,8 +39,8 @@ const PostHeader: FC = ({ tags={targetPost.metadata?.tags || []} timestamp={timestamp} /> - {!publication.isHidden && !quoted ? ( - + {!post.isHidden && !quoted ? ( + ) : (
)} @@ -50,7 +48,7 @@ const PostHeader: FC = ({