fix(publish): use active account at publish time instead of baking stale author data at typing time

This commit is contained in:
plebeius
2026-03-03 15:50:32 +08:00
parent 84e6057bb8
commit 422eacc5c1
2 changed files with 12 additions and 15 deletions
+6 -8
View File
@@ -1,10 +1,8 @@
import { useCallback } from 'react';
import { Comment, useAccount, usePublishComment } from '@bitsocialhq/pkc-react-hooks';
import { Comment, usePublishComment } from '@bitsocialhq/pkc-react-hooks';
import usePublishPostStore from '../stores/use-publish-post-store';
const usePublishPost = ({ subplebbitAddress }: { subplebbitAddress?: string }) => {
const account = useAccount();
const { author, title, content, link, spoiler, publishCommentOptions } = usePublishPostStore((state) => ({
author: state.author,
title: state.title || undefined,
@@ -26,13 +24,13 @@ const usePublishPost = ({ subplebbitAddress }: { subplebbitAddress?: string }) =
spoiler,
};
baseOptions.author = {
...account?.author,
displayName: author?.displayName || account?.author?.displayName,
};
const displayName = author?.displayName;
if (displayName) {
baseOptions.author = { displayName };
}
return baseOptions;
}, [author, content, link, spoiler, subplebbitAddress, title, account]);
}, [author, content, link, spoiler, subplebbitAddress, title]);
const setPublishPostOptions = useCallback(
(options: Partial<Comment>) => {
+6 -7
View File
@@ -1,12 +1,11 @@
import { useCallback, useMemo } from 'react';
import { Comment, useAccount, usePublishComment } from '@bitsocialhq/pkc-react-hooks';
import { Comment, usePublishComment } from '@bitsocialhq/pkc-react-hooks';
import usePublishReplyStore from '../stores/use-publish-reply-store';
import usePostNumberStore from '../stores/use-post-number-store';
import { getQuotedCidsFromContent, mergeQuotedCids } from '../lib/utils/reply-quote-utils';
const usePublishReply = ({ cid, subplebbitAddress, postCid }: { cid: string; subplebbitAddress: string; postCid?: string }) => {
const parentCid = cid;
const account = useAccount();
const { author, content, link, spoiler, publishCommentOptions } = usePublishReplyStore((state) => ({
author: state.author[parentCid],
@@ -29,13 +28,13 @@ const usePublishReply = ({ cid, subplebbitAddress, postCid }: { cid: string; sub
spoiler,
};
baseOptions.author = {
...account?.author,
displayName: author?.displayName || account?.author?.displayName,
};
const displayName = author?.displayName;
if (displayName) {
baseOptions.author = { displayName };
}
return baseOptions;
}, [author, content, link, parentCid, postCid, spoiler, subplebbitAddress, account]);
}, [author, content, link, parentCid, postCid, spoiler, subplebbitAddress]);
const setPublishReplyOptions = useCallback(
(options: Partial<Comment>) => {