clean code, better var names, fix bugs

This commit is contained in:
Tom (plebeius.eth)
2025-01-30 17:27:58 +01:00
parent 204fdfcace
commit 87164fc800
4 changed files with 35 additions and 34 deletions
+3 -3
View File
@@ -10,9 +10,9 @@ const usePublishPost = ({ subplebbitAddress }: { subplebbitAddress?: string }) =
const { author, signer, title, content, link, spoiler, publishCommentOptions } = usePublishPostStore((state) => ({
author: state.author,
signer: state.signer,
title: state.title === '' ? undefined : state.title,
content: state.content === '' ? undefined : state.content,
link: state.link === '' ? undefined : state.link,
title: state.title || undefined,
content: state.content || undefined,
link: state.link || undefined,
spoiler: state.spoiler || false,
publishCommentOptions: state.publishCommentOptions,
}));
+5 -5
View File
@@ -17,8 +17,8 @@ const usePublishReply = ({ cid, subplebbitAddress, postCid }: { cid: string; sub
publishCommentOptions: state.publishCommentOptions[parentCid],
}));
const setReplyStore = usePublishReplyStore((state) => state.setReplyStore);
const resetReplyStore = usePublishReplyStore((state) => state.resetReplyStore);
const setPublishReplyStore = usePublishReplyStore((state) => state.setPublishReplyStore);
const resetPublishReplyStore = usePublishReplyStore((state) => state.resetPublishReplyStore);
const createBaseOptions = useCallback(() => {
const baseOptions: Comment = {
@@ -55,12 +55,12 @@ const usePublishReply = ({ cid, subplebbitAddress, postCid }: { cid: string; sub
}, {} as Partial<Comment>);
const newOptions = { ...baseOptions, ...sanitizedOptions };
setReplyStore(newOptions);
setPublishReplyStore(newOptions);
},
[createBaseOptions, setReplyStore],
[createBaseOptions, setPublishReplyStore],
);
const resetPublishReplyOptions = useCallback(() => resetReplyStore(parentCid), [parentCid, resetReplyStore]);
const resetPublishReplyOptions = useCallback(() => resetPublishReplyStore(parentCid), [parentCid, resetPublishReplyStore]);
const { index, publishComment } = usePublishComment(publishCommentOptions);