Skip to content

Commit

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

Highlights:

β€’ Updated imports and usage from `usePublicationStore` to `usePostStore`.
β€’ Created new stores like `usePostAttributesStore` and `usePostAudioStore`.
β€’ Added `usePostMetadata` hook to handle post metadata operations.

Read more: https://pierre.co/hey/hey/pre-lens-v3
  • Loading branch information
Yoginth authored and Pierre committed Nov 13, 2024
1 parent 829be32 commit 1b50e17
Show file tree
Hide file tree
Showing 24 changed files with 72 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { CollectModuleType } from "@hey/types/hey";
import { Button } from "@hey/ui";
import type { Dispatch, FC, SetStateAction } from "react";
import { useCollectModuleStore } from "src/store/non-persisted/publication/useCollectModuleStore";
import { usePublicationLicenseStore } from "src/store/non-persisted/publication/usePublicationLicenseStore";
import { usePostLicenseStore } from "src/store/non-persisted/publication/usePostLicenseStore";
import { isAddress } from "viem";
import AmountConfig from "./AmountConfig";
import CollectLimitConfig from "./CollectLimitConfig";
Expand All @@ -22,7 +22,7 @@ const CollectForm: FC<CollectFormProps> = ({ setShowModal }) => {
const { collectModule, reset, setCollectModule } = useCollectModuleStore(
(state) => state
);
const { setLicense } = usePublicationLicenseStore();
const { setLicense } = usePostLicenseStore();

const { SimpleCollectOpenActionModule } = CollectOpenActionModuleType;
const recipients = collectModule.recipients || [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Modal, Tooltip } from "@hey/ui";
import type { FC } from "react";
import { useState } from "react";
import { useCollectModuleStore } from "src/store/non-persisted/publication/useCollectModuleStore";
import { usePublicationLicenseStore } from "src/store/non-persisted/publication/usePublicationLicenseStore";
import { usePostLicenseStore } from "src/store/non-persisted/publication/usePostLicenseStore";
import CollectForm from "./CollectForm";

const CollectSettings: FC = () => {
const { reset } = useCollectModuleStore((state) => state);
const { setLicense } = usePublicationLicenseStore();
const { setLicense } = usePostLicenseStore();
const [showModal, setShowModal] = useState(false);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import axios from "axios";
import type { FC, ReactNode } from "react";
import { useState } from "react";
import toast from "react-hot-toast";
import { usePublicationLiveStore } from "src/store/non-persisted/publication/usePublicationLiveStore";
import { usePostLiveStore } from "src/store/non-persisted/publication/usePostLiveStore";

interface WrapperProps {
children: ReactNode;
Expand All @@ -34,7 +34,7 @@ const LivestreamEditor: FC = () => {
resetLiveVideoConfig,
setLiveVideoConfig,
setShowLiveVideoEditor
} = usePublicationLiveStore();
} = usePostLiveStore();

const [screen, setScreen] = useState<"create" | "record">("create");
const [creating, setCreating] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Tooltip } from "@hey/ui";
import cn from "@hey/ui/cn";
import type { FC } from "react";
import { usePostAttachmentStore } from "src/store/non-persisted/publication/usePostAttachmentStore";
import { usePublicationLiveStore } from "src/store/non-persisted/publication/usePublicationLiveStore";
import { usePostLiveStore } from "src/store/non-persisted/publication/usePostLiveStore";

const LivestreamSettings: FC = () => {
const { resetLiveVideoConfig, setShowLiveVideoEditor, showLiveVideoEditor } =
usePublicationLiveStore();
usePostLiveStore();
const { attachments } = usePostAttachmentStore((state) => state);
const disable = attachments.length > 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Button, Card, Input, Modal, Tooltip } from "@hey/ui";
import plur from "plur";
import type { FC } from "react";
import { useState } from "react";
import { usePublicationPollStore } from "src/store/non-persisted/publication/usePublicationPollStore";
import { usePostPollStore } from "src/store/non-persisted/publication/usePostPollStore";

const PollEditor: FC = () => {
const { pollConfig, resetPollConfig, setPollConfig, setShowPollEditor } =
usePublicationPollStore();
usePostPollStore();
const [showPollLengthModal, setShowPollLengthModal] = useState(false);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Bars3BottomLeftIcon } from "@heroicons/react/24/solid";
import { Tooltip } from "@hey/ui";
import type { FC } from "react";
import { usePublicationPollStore } from "src/store/non-persisted/publication/usePublicationPollStore";
import { usePostPollStore } from "src/store/non-persisted/publication/usePostPollStore";

const PollSettings: FC = () => {
const { resetPollConfig, setShowPollEditor, showPollEditor } =
usePublicationPollStore();
usePostPollStore();

return (
<Tooltip content="Poll" placement="top">
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/components/Composer/Editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { htmlFromMarkdown } from "@helpers/prosekit/markdown";
import getAvatar from "@hey/helpers/getAvatar";
import { Image } from "@hey/ui";
import dynamic from "next/dynamic";
import type { FC } from "react";
import "prosekit/basic/style.css";
import { createEditor } from "prosekit/core";
import { ProseKit } from "prosekit/react";
import type { FC } from "react";
import { useMemo, useRef } from "react";
import useContentChange from "src/hooks/prosekit/useContentChange";
import useFocus from "src/hooks/prosekit/useFocus";
import { usePaste } from "src/hooks/prosekit/usePaste";
import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore";
import { usePostStore } from "src/store/non-persisted/publication/usePostStore";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useEditorHandle } from "./EditorHandle";

Expand All @@ -20,7 +20,7 @@ const EditorMenus = dynamic(() => import("./EditorMenus"), { ssr: false });

const Editor: FC = () => {
const { currentProfile } = useProfileStore();
const { publicationContent } = usePublicationStore();
const { publicationContent } = usePostStore();
const defaultMarkdownRef = useRef(publicationContent);

const defaultContent = useMemo(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Composer/LicensePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Select, Tooltip } from "@hey/ui";
import { MetadataLicenseType } from "@lens-protocol/metadata";
import Link from "next/link";
import type { FC } from "react";
import { usePublicationLicenseStore } from "src/store/non-persisted/publication/usePublicationLicenseStore";
import { usePostLicenseStore } from "src/store/non-persisted/publication/usePostLicenseStore";

const LicensePicker: FC = () => {
const { license, setLicense } = usePublicationLicenseStore();
const { license, setLicense } = usePostLicenseStore();

const otherOptions = Object.values(MetadataLicenseType)
.filter((type) => getAssetLicense(type))
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Composer/LinkPreviews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { MetadataAttributeType } from "@lens-protocol/metadata";
import type { FC } from "react";
import { useEffect, useState } from "react";
import { usePostAttachmentStore } from "src/store/non-persisted/publication/usePostAttachmentStore";
import { usePublicationAttributesStore } from "src/store/non-persisted/publication/usePublicationAttributesStore";
import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore";
import { usePostAttributesStore } from "src/store/non-persisted/publication/usePostAttributesStore";
import { usePostStore } from "src/store/non-persisted/publication/usePostStore";

const LinkPreviews: FC = () => {
const { publicationContent, quotedPost } = usePublicationStore();
const { publicationContent, quotedPost } = usePostStore();
const { attachments } = usePostAttachmentStore((state) => state);
const { addAttribute, getAttribute, removeAttribute } =
usePublicationAttributesStore();
usePostAttributesStore();
const [showRemove, setShowRemove] = useState(false);

const urls = getURLs(publicationContent);
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Composer/NewPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Card, Image } from "@hey/ui";
import { useRouter } from "next/router";
import type { FC } from "react";
import { useEffect, useState } from "react";
import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore";
import { usePostStore } from "src/store/non-persisted/publication/usePostStore";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import NewPublication from "./NewPublication";

Expand All @@ -15,7 +15,7 @@ interface NewPostProps {
const NewPost: FC<NewPostProps> = ({ tags }) => {
const { isReady, query } = useRouter();
const { currentProfile } = useProfileStore();
const { setPublicationContent, setTags } = usePublicationStore();
const { setPublicationContent, setTags } = usePostStore();
const [showComposer, setShowComposer] = useState(false);

const handleOpenModal = () => {
Expand Down
34 changes: 17 additions & 17 deletions apps/web/src/components/Composer/NewPublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ import { useEffect, useState } from "react";
import toast from "react-hot-toast";
import useCreatePoll from "src/hooks/useCreatePoll";
import useCreatePublication from "src/hooks/useCreatePublication";
import usePublicationMetadata from "src/hooks/usePublicationMetadata";
import usePostMetadata from "src/hooks/usePostMetadata";
import { useCollectModuleStore } from "src/store/non-persisted/publication/useCollectModuleStore";
import { usePostAttachmentStore } from "src/store/non-persisted/publication/usePostAttachmentStore";
import { usePostAttributesStore } from "src/store/non-persisted/publication/usePostAttributesStore";
import {
DEFAULT_AUDIO_PUBLICATION,
usePostAudioStore
} from "src/store/non-persisted/publication/usePostAudioStore";
import { usePostLicenseStore } from "src/store/non-persisted/publication/usePostLicenseStore";
import { usePostLiveStore } from "src/store/non-persisted/publication/usePostLiveStore";
import { usePostPollStore } from "src/store/non-persisted/publication/usePostPollStore";
import { usePostStore } from "src/store/non-persisted/publication/usePostStore";
import {
DEFAULT_VIDEO_THUMBNAIL,
usePostVideoStore
} from "src/store/non-persisted/publication/usePostVideoStore";
import { usePublicationAttributesStore } from "src/store/non-persisted/publication/usePublicationAttributesStore";
import {
DEFAULT_AUDIO_PUBLICATION,
usePublicationAudioStore
} from "src/store/non-persisted/publication/usePublicationAudioStore";
import { usePublicationLicenseStore } from "src/store/non-persisted/publication/usePublicationLicenseStore";
import { usePublicationLiveStore } from "src/store/non-persisted/publication/usePublicationLiveStore";
import { usePublicationPollStore } from "src/store/non-persisted/publication/usePublicationPollStore";
import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore";
import { useGlobalModalStateStore } from "src/store/non-persisted/useGlobalModalStateStore";
import { useNonceStore } from "src/store/non-persisted/useNonceStore";
import { useProfileStatus } from "src/store/non-persisted/useProfileStatus";
Expand Down Expand Up @@ -111,28 +111,28 @@ const NewPublication: FC<NewPublicationProps> = ({ className, post }) => {
setPublicationContent,
setQuotedPost,
setTags
} = usePublicationStore();
} = usePostStore();

// Audio store
const { audioPublication, setAudioPublication } = usePublicationAudioStore();
const { audioPublication, setAudioPublication } = usePostAudioStore();

// Video store
const { setVideoThumbnail, videoThumbnail } = usePostVideoStore();

// Live video store
const { resetLiveVideoConfig, setShowLiveVideoEditor, showLiveVideoEditor } =
usePublicationLiveStore();
usePostLiveStore();

// Attachment store
const { addAttachments, attachments, isUploading, setAttachments } =
usePostAttachmentStore((state) => state);

// Poll store
const { pollConfig, resetPollConfig, setShowPollEditor, showPollEditor } =
usePublicationPollStore();
usePostPollStore();

// License store
const { setLicense } = usePublicationLicenseStore();
const { setLicense } = usePostLicenseStore();

// Collect module store
const { collectModule, reset: resetCollectSettings } = useCollectModuleStore(
Expand All @@ -144,7 +144,7 @@ const NewPublication: FC<NewPublicationProps> = ({ className, post }) => {
useReferenceModuleStore();

// Attributes store
const { reset: resetAttributes } = usePublicationAttributesStore();
const { reset: resetAttributes } = usePostAttributesStore();

// States
const [isLoading, setIsLoading] = useState(false);
Expand All @@ -154,7 +154,7 @@ const NewPublication: FC<NewPublicationProps> = ({ className, post }) => {

const editor = useEditorContext();
const createPoll = useCreatePoll();
const getMetadata = usePublicationMetadata();
const getMetadata = usePostMetadata();

const { canUseLensManager } = checkDispatcherPermissions(currentProfile);

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Publication/Actions/Share/Quote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TriStateValue } from "@hey/lens";
import cn from "@hey/ui/cn";
import type { FC } from "react";
import toast from "react-hot-toast";
import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore";
import { usePostStore } from "src/store/non-persisted/publication/usePostStore";
import { useGlobalModalStateStore } from "src/store/non-persisted/useGlobalModalStateStore";
import { useProfileStatus } from "src/store/non-persisted/useProfileStatus";
import { useProfileStore } from "src/store/persisted/useProfileStore";
Expand All @@ -18,7 +18,7 @@ interface QuoteProps {
const Quote: FC<QuoteProps> = ({ post }) => {
const { currentProfile } = useProfileStore();
const { setShowAuthModal, setShowNewPostModal } = useGlobalModalStateStore();
const { setQuotedPost } = usePublicationStore();
const { setQuotedPost } = usePostStore();
const { isSuspended } = useProfileStatus();
const publicationType = post.__typename;

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Publication/PostHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isRepost } from "@hey/helpers/postHelpers";
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 { usePostStore } from "src/store/non-persisted/publication/usePostStore";
import PostMenu from "./Actions/Menu";

interface PostHeaderProps {
Expand All @@ -20,7 +20,7 @@ const PostHeader: FC<PostHeaderProps> = ({
post,
quoted = false
}) => {
const { setQuotedPost } = usePublicationStore();
const { setQuotedPost } = usePostStore();

const targetPost = isRepost(post) ? post?.mirrorOn : post;
const rootPublication = feedItem ? feedItem?.root : targetPost;
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Shared/Audio/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { AnyPublication, Profile } from "@hey/lens";
import type { APITypes } from "plyr-react";
import type { ChangeEvent, FC } from "react";
import { useRef, useState } from "react";
import { usePublicationAudioStore } from "src/store/non-persisted/publication/usePublicationAudioStore";
import { usePostAudioStore } from "src/store/non-persisted/publication/usePostAudioStore";
import { object, string } from "zod";
import CoverImage from "./CoverImage";
import Player from "./Player";
Expand Down Expand Up @@ -37,7 +37,7 @@ const Audio: FC<AudioProps> = ({
src,
title
}) => {
const { audioPublication, setAudioPublication } = usePublicationAudioStore();
const { audioPublication, setAudioPublication } = usePostAudioStore();
const [newPreviewUri, setNewPreviewUri] = useState<null | string>(null);
const [playing, setPlaying] = useState(false);
const playerRef = useRef<APITypes>(null);
Expand Down
5 changes: 2 additions & 3 deletions apps/web/src/hooks/prosekit/useContentChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import type { Editor } from "prosekit/core";
import { useDocChange } from "prosekit/react";
import { useCallback, useState } from "react";
import useDebouncedCallback from "src/hooks/prosekit/useDebouncedCallback";
import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore";
import { usePostStore } from "src/store/non-persisted/publication/usePostStore";

const DEBOUNCE_CHARS_THRESHOLD = 3000;
const DEBOUNCE_DELAY = 500;

const useContentChange = (editor: Editor<EditorExtension>) => {
const { setPublicationContent } = usePublicationStore();

const { setPublicationContent } = usePostStore();
const [largeDocument, setLargeDocument] = useState(false);

const setContent = useCallback(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/hooks/useCreatePoll.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { getAuthApiHeaders } from "@helpers/getAuthApiHeaders";
import { HEY_API_URL } from "@hey/data/constants";
import axios from "axios";
import { usePublicationPollStore } from "src/store/non-persisted/publication/usePublicationPollStore";
import { usePostPollStore } from "src/store/non-persisted/publication/usePostPollStore";

type CreatePollResponse = string;

const useCreatePoll = () => {
const { pollConfig } = usePublicationPollStore();
const { pollConfig } = usePostPollStore();

// TODO: use useCallback
const createPoll = async (): Promise<CreatePollResponse> => {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/hooks/useCreatePublication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
import { OptmisticPublicationType } from "@hey/types/enums";
import type { OptimisticTransaction } from "@hey/types/misc";
import { useRouter } from "next/router";
import { usePublicationStore } from "src/store/non-persisted/publication/usePublicationStore";
import { usePostStore } from "src/store/non-persisted/publication/usePostStore";
import { useNonceStore } from "src/store/non-persisted/useNonceStore";
import { useProfileStore } from "src/store/persisted/useProfileStore";
import { useTransactionStore } from "src/store/persisted/useTransactionStore";
Expand Down Expand Up @@ -62,7 +62,7 @@ const useCreatePublication = ({
incrementLensHubOnchainSigNonce,
lensHubOnchainSigNonce
} = useNonceStore();
const { publicationContent } = usePublicationStore();
const { publicationContent } = usePostStore();
const { addTransaction } = useTransactionStore();
const handleWrongNetwork = useHandleWrongNetwork();
const { canBroadcast } = checkDispatcherPermissions(currentProfile);
Expand Down
Loading

1 comment on commit 1b50e17

@vercel
Copy link

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

Please sign in to comment.