mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix anon mode bug with post form for posts
This commit is contained in:
@@ -44,6 +44,7 @@ const { addChallenge } = useChallengesStore.getState();
|
|||||||
|
|
||||||
const useSubmitStore = create<SubmitState>((set) => ({
|
const useSubmitStore = create<SubmitState>((set) => ({
|
||||||
author: undefined,
|
author: undefined,
|
||||||
|
displayName: undefined,
|
||||||
signer: undefined,
|
signer: undefined,
|
||||||
subplebbitAddress: undefined,
|
subplebbitAddress: undefined,
|
||||||
title: undefined,
|
title: undefined,
|
||||||
@@ -91,6 +92,7 @@ const useSubmitStore = create<SubmitState>((set) => ({
|
|||||||
resetSubmitStore: () =>
|
resetSubmitStore: () =>
|
||||||
set({
|
set({
|
||||||
author: undefined,
|
author: undefined,
|
||||||
|
displayName: undefined,
|
||||||
signer: undefined,
|
signer: undefined,
|
||||||
subplebbitAddress: undefined,
|
subplebbitAddress: undefined,
|
||||||
title: undefined,
|
title: undefined,
|
||||||
@@ -154,17 +156,28 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
|
|||||||
const hasCalledAnonAddressRef = useRef(false);
|
const hasCalledAnonAddressRef = useRef(false);
|
||||||
|
|
||||||
const getAnonAddressForPost = useCallback(async () => {
|
const getAnonAddressForPost = useCallback(async () => {
|
||||||
if (anonMode && !hasCalledAnonAddressRef.current) {
|
if (anonMode) {
|
||||||
hasCalledAnonAddressRef.current = true;
|
if (!hasCalledAnonAddressRef.current) {
|
||||||
const newSigner = (await getNewSigner()) || {};
|
hasCalledAnonAddressRef.current = true;
|
||||||
|
const newSigner = (await getNewSigner()) || {};
|
||||||
|
setSubmitStore({
|
||||||
|
signer: newSigner,
|
||||||
|
author: {
|
||||||
|
address: newSigner.address,
|
||||||
|
displayName: account?.author?.displayName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
setSubmitStore({
|
setSubmitStore({
|
||||||
signer: newSigner,
|
signer: undefined,
|
||||||
author: {
|
author: {
|
||||||
address: newSigner.address,
|
address: account?.author?.address,
|
||||||
|
displayName: account?.author?.displayName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [anonMode, getNewSigner, setSubmitStore]);
|
}, [anonMode, getNewSigner, account, setSubmitStore]);
|
||||||
|
|
||||||
const onPublishPost = async () => {
|
const onPublishPost = async () => {
|
||||||
if (!title && !content && !link) {
|
if (!title && !content && !link) {
|
||||||
@@ -176,6 +189,16 @@ const PostFormTable = ({ closeForm, postCid }: { closeForm: () => void; postCid:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!anonMode) {
|
||||||
|
setSubmitStore({
|
||||||
|
signer: undefined,
|
||||||
|
author: {
|
||||||
|
address: account?.author?.address,
|
||||||
|
displayName: account?.author?.displayName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
publishComment();
|
publishComment();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user