diff --git a/src/components/post-form/post-form.tsx b/src/components/post-form/post-form.tsx index 57e13dee..65d83ebb 100644 --- a/src/components/post-form/post-form.tsx +++ b/src/components/post-form/post-form.tsx @@ -131,6 +131,12 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid: const { link, publishCommentOptions, setSubmitStore, resetSubmitStore } = useSubmitStore(); const { index, publishComment } = usePublishComment(publishCommentOptions); + useEffect(() => { + if (displayName) { + setSubmitStore({ displayName }); + } + }, [displayName, setSubmitStore]); + const textRef = useRef(null); const urlRef = useRef(null); const subjectRef = useRef(null); diff --git a/src/hooks/use-publish-reply.ts b/src/hooks/use-publish-reply.ts index 87f59aa0..e73ddfef 100644 --- a/src/hooks/use-publish-reply.ts +++ b/src/hooks/use-publish-reply.ts @@ -93,23 +93,22 @@ const useReplyStore = create((set) => ({ const useReply = ({ cid, subplebbitAddress }: { cid: string; subplebbitAddress: string }) => { const parentCid = cid; + const account = useAccount(); + const { anonMode } = useAnonMode(); + const { author, signer, content, link, spoiler, publishCommentOptions } = useReplyStore((state) => ({ - author: state.author[parentCid], - displayName: state.displayName[parentCid], + author: state.author[parentCid] || (account?.author ? { ...account.author, displayName: account.author.displayName || undefined } : undefined), + displayName: state.displayName[parentCid] || account?.author?.displayName, signer: state.signer[parentCid], - content: state.content[parentCid], + content: state.content[parentCid] || '', link: state.link[parentCid], - spoiler: state.spoiler[parentCid], + spoiler: state.spoiler[parentCid] || false, publishCommentOptions: state.publishCommentOptions[parentCid], })); - const { anonMode } = useAnonMode(); - const setReplyStore = useReplyStore((state) => state.setReplyStore); const resetReplyStore = useReplyStore((state) => state.resetReplyStore); - const account = useAccount(); - const setPublishReplyOptions = useCallback( (options: Partial) => { const newOptions: Partial = { @@ -118,6 +117,7 @@ const useReply = ({ cid, subplebbitAddress }: { cid: string; subplebbitAddress: content: options.content ?? content, link: options.link ?? link, spoiler: options.spoiler ?? spoiler, + displayName: options.displayName ?? author?.displayName ?? account?.author?.displayName, }; if ('displayName' in options) {