mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(publish): use active account at publish time instead of baking stale author data at typing time
This commit is contained in:
@@ -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>) => {
|
||||
|
||||
@@ -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>) => {
|
||||
|
||||
Reference in New Issue
Block a user