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>) => {
|
||||
|
||||
Reference in New Issue
Block a user