Skip to content

Commit

Permalink
πŸ” Rename publication to post for v3 preparation: v4 (#pre-lens-v3)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Yoginth authored and Pierre committed Nov 13, 2024
1 parent 714329d commit 1245307
Show file tree
Hide file tree
Showing 37 changed files with 209 additions and 234 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/components/Composer/LinkPreviews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -27,7 +27,7 @@ const LinkPreviews: FC = () => {
if (
!urls.length ||
attachments.length ||
quotedPublication ||
quotedPost ||
getAttribute(KNOWN_ATTRIBUTES.HIDE_OEMBED)?.value === "true"
) {
return null;
Expand Down
43 changes: 20 additions & 23 deletions apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,10 @@ const LivestreamSettings = dynamic(

interface NewPublicationProps {
className?: string;
publication?: MirrorablePublication;
post?: MirrorablePublication;
}

const NewPublication: FC<NewPublicationProps> = ({
className,
publication
}) => {
const NewPublication: FC<NewPublicationProps> = ({ className, post }) => {
const { currentProfile } = useProfileStore();
const { isSuspended } = useProfileStatus();

Expand All @@ -110,9 +107,9 @@ const NewPublication: FC<NewPublicationProps> = ({
// Publication store
const {
publicationContent,
quotedPublication,
quotedPost,
setPublicationContent,
setQuotedPublication,
setQuotedPost,
setTags
} = usePublicationStore();

Expand Down Expand Up @@ -161,17 +158,17 @@ const NewPublication: FC<NewPublicationProps> = ({

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 = () => {
Expand All @@ -184,7 +181,7 @@ const NewPublication: FC<NewPublicationProps> = ({
setShowLiveVideoEditor(false);
resetLiveVideoConfig();
setAttachments([]);
setQuotedPublication(null);
setQuotedPost(null);
setVideoThumbnail(DEFAULT_VIDEO_THUMBNAIL);
setAudioPublication(DEFAULT_AUDIO_PUBLICATION);
setLicense(null);
Expand Down Expand Up @@ -217,7 +214,7 @@ const NewPublication: FC<NewPublicationProps> = ({

// 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,
Expand All @@ -228,7 +225,7 @@ const NewPublication: FC<NewPublicationProps> = ({
ReferenceModuleType.DegreesOfSeparationReferenceModule
? degreesOfSeparation
: null,
quote_on: isQuote ? quotedPublication?.id : null
quote_on: isQuote ? quotedPost?.id : null
};
Leafwatch.track(
isComment
Expand All @@ -255,10 +252,10 @@ const NewPublication: FC<NewPublicationProps> = ({
createQuoteOnMomka,
error
} = useCreatePublication({
commentOn: publication,
commentOn: post,
onCompleted,
onError,
quoteOn: quotedPublication as Quote
quoteOn: quotedPost as Quote
});

useEffect(() => {
Expand Down Expand Up @@ -379,8 +376,8 @@ const NewPublication: FC<NewPublicationProps> = ({
| MomokaCommentRequest
| MomokaPostRequest
| MomokaQuoteRequest = {
...(isComment && { commentOn: publication?.id }),
...(isQuote && { quoteOn: quotedPublication?.id }),
...(isComment && { commentOn: post?.id }),
...(isQuote && { quoteOn: quotedPost?.id }),
contentURI: `${METADATA_ENDPOINT}/${metadataId}`
};

Expand Down Expand Up @@ -424,8 +421,8 @@ const NewPublication: FC<NewPublicationProps> = ({
| 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:
Expand Down Expand Up @@ -522,9 +519,9 @@ const NewPublication: FC<NewPublicationProps> = ({
{showLiveVideoEditor ? <LivestreamEditor /> : null}
<LinkPreviews />
<NewAttachments attachments={attachments} />
{quotedPublication ? (
{quotedPost ? (
<Wrapper className="m-5" zeroPadding>
<QuotedPost isNew post={removeQuoteOn(quotedPublication as Quote)} />
<QuotedPost isNew post={removeQuoteOn(quotedPost as Quote)} />
</Wrapper>
) : null}
<div className="divider mx-5" />
Expand All @@ -540,7 +537,7 @@ const NewPublication: FC<NewPublicationProps> = ({
showEmojiPicker={showEmojiPicker}
/>
<Gif setGifAttachment={(gif: IGif) => setGifAttachment(gif)} />
{publication?.momoka?.proof ? null : (
{post?.momoka?.proof ? null : (
<>
<CollectSettings />
<ReferenceSettings />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import type { FC } from "react";

interface OpenActionPaidActionProps {
latestActed: LatestActed[];
publication: AnyPublication;
post: AnyPublication;
}

const OpenActionPaidAction: FC<OpenActionPaidActionProps> = ({
latestActed,
publication
post
}) => {
const targetPost = isRepost(publication) ? publication.mirrorOn : publication;
const targetPost = isRepost(post) ? post.mirrorOn : post;

const openActions = targetPost.openActionModules
.filter(
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 @@ -60,7 +60,7 @@ const PaidActions: FC = () => {
<Card>
<OpenActionPaidAction
latestActed={action.latestActed as LatestActed[]}
publication={action.actedOn as AnyPublication}
post={action.actedOn as AnyPublication}
/>
<div className="divider" />
<SinglePost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const Mint: FC<MintProps> = ({ onCollectSuccess }) => {
);
}

const publication = data?.publication as Post;
const openAction = publication.openActionModules[0];
const post = data?.publication as Post;
const openAction = post.openActionModules[0];

return (
<div className="p-5">
Expand Down Expand Up @@ -92,7 +92,7 @@ const Mint: FC<MintProps> = ({ onCollectSuccess }) => {
}
onCollectSuccess={onCollectSuccess}
openAction={openAction}
publication={publication}
post={post}
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Mod/LatestFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const LatestFeed: FC = () => {
showThread={false}
/>
<div className="divider" />
<HigherActions publication={post as MirrorablePublication} />
<HigherActions post={post as MirrorablePublication} />
</Card>
)}
useWindowScroll
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Mod/ReportsFeed/ReportDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const ReportDetails: FC<ReportDetailsProps> = ({
<Dispute report={report} setShowDisputeModal={setShowDisputeModal} />
</Modal>
<StaffActions
publication={report.reportedPublication as MirrorablePublication}
post={report.reportedPublication as MirrorablePublication}
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/Mod/SearchFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const SearchFeed: FC = () => {
showThread={false}
/>
<div className="divider" />
<HigherActions publication={targetPost} />
<HigherActions post={targetPost} />
</Card>
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GardenerActionsProps> = ({ publication }) => {
const GardenerActions: FC<GardenerActionsProps> = ({ post }) => {
const { pathname } = useRouter();
const { setShowGardenerActionsAlert } = useGlobalAlertStateStore();
const [loading, setLoading] = useState(false);
Expand All @@ -29,14 +29,14 @@ const GardenerActions: FC<GardenerActionsProps> = ({ 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 {
Expand All @@ -53,7 +53,7 @@ const GardenerActions: FC<GardenerActionsProps> = ({ publication }) => {
type: string;
}) => {
Leafwatch.track(GARDENER.REPORT, {
publication_id: publication.id,
publication_id: post.id,
type
});
toast.promise(reportPublicationOnLens(subreasons), {
Expand Down Expand Up @@ -125,7 +125,7 @@ const GardenerActions: FC<GardenerActionsProps> = ({ publication }) => {
type: "suspend"
});
}}
publication={publication}
post={post}
/>
</div>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import { toast } from "react-hot-toast";

interface StaffActionsProps {
onClick?: () => void;
publication: MirrorablePublication;
post: MirrorablePublication;
}

const StaffActions: FC<StaffActionsProps> = ({ onClick, publication }) => {
const StaffActions: FC<StaffActionsProps> = ({ 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
});

Expand All @@ -37,7 +37,7 @@ const StaffActions: FC<StaffActionsProps> = ({ 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() }
),
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import type { FC } from "react";
import GardenerActions from "./GardenerActions";

interface HigherActionsProps {
publication: MirrorablePublication;
post: MirrorablePublication;
}

const HigherActions: FC<HigherActionsProps> = ({ publication }) => {
const HigherActions: FC<HigherActionsProps> = ({ post }) => {
return (
<div className="m-5">
<GardenerActions publication={publication} />
<GardenerActions post={post} />
</div>
);
};
Expand Down
22 changes: 11 additions & 11 deletions apps/web/src/components/Publication/Actions/Menu/Bookmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import type { FC } from "react";
import { toast } from "react-hot-toast";

interface BookmarkProps {
publication: MirrorablePublication;
post: MirrorablePublication;
}

const Bookmark: FC<BookmarkProps> = ({ publication }) => {
const Bookmark: FC<BookmarkProps> = ({ 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<any>) => {
Expand All @@ -40,32 +40,32 @@ const Bookmark: FC<BookmarkProps> = ({ 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) });
}
};

const onError = (error: any) => {
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) => {
Expand All @@ -81,7 +81,7 @@ const Bookmark: FC<BookmarkProps> = ({ publication }) => {
onCompleted: () => {
toast.success("Removed publication bookmark!");
Leafwatch.track(PUBLICATION.REMOVE_BOOKMARK, {
publication_id: publication.id
publication_id: post.id
});
},
onError: (error) => {
Expand Down
Loading

1 comment on commit 1245307

@vercel
Copy link

@vercel vercel bot commented on 1245307 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
web-heyxyz.vercel.app
hey.xyz
web-git-main-heyxyz.vercel.app

Please sign in to comment.