refactor use-publish-reply

This commit is contained in:
Tom (plebeius.eth)
2024-11-05 12:02:01 +01:00
parent 82217a726c
commit aa3b3a8b5d
2 changed files with 8 additions and 19 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
import { useCallback } from 'react';
import { useAccount, usePublishComment } from '@plebbit/plebbit-react-hooks';
import { Comment, useAccount, usePublishComment } from '@plebbit/plebbit-react-hooks';
import useAnonMode from './use-anon-mode';
import usePublishReplyStore, { SetReplyStoreData } from '../stores/use-publish-reply-store';
import usePublishReplyStore from '../stores/use-publish-reply-store';
const usePublishReply = ({ cid, subplebbitAddress }: { cid: string; subplebbitAddress: string }) => {
const parentCid = cid;
@@ -22,8 +22,8 @@ const usePublishReply = ({ cid, subplebbitAddress }: { cid: string; subplebbitAd
const resetReplyStore = usePublishReplyStore((state) => state.resetReplyStore);
const setPublishReplyOptions = useCallback(
(options: Partial<SetReplyStoreData>) => {
const newOptions: Partial<SetReplyStoreData> = {
(options: Comment) => {
const newOptions: Comment = {
subplebbitAddress,
parentCid,
content: options.content === '' ? undefined : options.content ?? content,
@@ -51,7 +51,7 @@ const usePublishReply = ({ cid, subplebbitAddress }: { cid: string; subplebbitAd
};
}
setReplyStore(newOptions as SetReplyStoreData);
setReplyStore(newOptions);
},
[subplebbitAddress, parentCid, author, signer, content, link, spoiler, setReplyStore, anonMode, account],
);