From 62e041ae91e02dae37d3d455e560aa840dad7840 Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Tue, 6 Aug 2024 21:57:28 +0200 Subject: [PATCH] rename file --- src/components/post-form/post-form.tsx | 11 +++++++++-- src/components/reply-modal/reply-modal.tsx | 4 ++-- src/hooks/{use-reply.ts => use-publish-reply.ts} | 0 3 files changed, 11 insertions(+), 4 deletions(-) rename src/hooks/{use-reply.ts => use-publish-reply.ts} (100%) diff --git a/src/components/post-form/post-form.tsx b/src/components/post-form/post-form.tsx index 14713720..e1b6b1a3 100644 --- a/src/components/post-form/post-form.tsx +++ b/src/components/post-form/post-form.tsx @@ -18,7 +18,7 @@ import { getLinkMediaInfo } from '../../lib/utils/media-utils'; import { isValidURL } from '../../lib/utils/url-utils'; import { isAllView, isDescriptionView, isPostPageView, isRulesView, isSubscriptionsView } from '../../lib/utils/view-utils'; import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits'; -import useReply from '../../hooks/use-reply'; +import usePublishReply from '../../hooks/use-publish-reply'; import useChallengesStore from '../../stores/use-challenges-store'; import styles from './post-form.module.css'; import _ from 'lodash'; @@ -193,7 +193,7 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid: // in post page, publish a reply to the post const isInPostView = isPostPageView(location.pathname, params); const cid = params?.commentCid as string; - const { setPublishReplyOptions, resetPublishReplyOptions, replyIndex, publishReply } = useReply({ cid, subplebbitAddress }); + const { setPublishReplyOptions, resetPublishReplyOptions, replyIndex, publishReply } = usePublishReply({ cid, subplebbitAddress }); const getAnonAddressForReply = useCallback(async () => { if (anonMode && !hasCalledAnonAddressRef.current) { @@ -256,6 +256,13 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid: } }, [anonMode, getAnonAddressForPost, getAnonAddressForReply, isInPostView]); + useEffect(() => { + if (subplebbitAddress) { + resetSubmitStore(); + resetPublishReplyOptions(); + } + }, [subplebbitAddress, resetSubmitStore, resetPublishReplyOptions]); + return ( diff --git a/src/components/reply-modal/reply-modal.tsx b/src/components/reply-modal/reply-modal.tsx index 55234ca7..f320a9f8 100644 --- a/src/components/reply-modal/reply-modal.tsx +++ b/src/components/reply-modal/reply-modal.tsx @@ -8,7 +8,7 @@ import { getFormattedTimeAgo } from '../../lib/utils/time-utils'; import { isValidURL } from '../../lib/utils/url-utils'; import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils'; import useSelectedTextStore from '../../stores/use-selected-text-store'; -import useReply from '../../hooks/use-reply'; +import usePublishReply from '../../hooks/use-publish-reply'; import useIsMobile from '../../hooks/use-is-mobile'; import styles from './reply-modal.module.css'; import { LinkTypePreviewer } from '../post-form'; @@ -25,7 +25,7 @@ interface ReplyModalProps { const ReplyModal = ({ closeModal, parentCid, postCid, scrollY }: ReplyModalProps) => { const { t } = useTranslation(); const { subplebbitAddress } = useParams() as { subplebbitAddress: string }; - const { setPublishReplyOptions, publishReply } = useReply({ cid: parentCid, subplebbitAddress }); + const { setPublishReplyOptions, publishReply } = usePublishReply({ cid: parentCid, subplebbitAddress }); const account = useAccount(); const { displayName } = account?.author || {}; const [url, setUrl] = useState(''); diff --git a/src/hooks/use-reply.ts b/src/hooks/use-publish-reply.ts similarity index 100% rename from src/hooks/use-reply.ts rename to src/hooks/use-publish-reply.ts