mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor: remove broken anon mode feature
- delete the anon mode hook/store and stop wiring publish flows through alternate signers - strip the settings UI, avatar warning, reply indicators, and FAQ text that referenced the toggle - drop the anon mode translation keys via scripts/update-translations.js
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { useMemo } from 'react';
|
||||
import { useAccount } from '@plebbit/plebbit-react-hooks';
|
||||
import useSubplebbitsStore from '@plebbit/plebbit-react-hooks/dist/stores/subplebbits';
|
||||
import useAnonModeStore from '../stores/use-anon-mode-store';
|
||||
import useAnonMode from './use-anon-mode';
|
||||
|
||||
interface AuthorPrivilegesProps {
|
||||
commentAuthorAddress: string;
|
||||
@@ -15,26 +13,16 @@ const useAuthorPrivileges = ({ commentAuthorAddress, subplebbitAddress, postCid
|
||||
const accountAuthorAddress = account?.author?.address;
|
||||
const subplebbit = useSubplebbitsStore((state) => state.subplebbits[subplebbitAddress]);
|
||||
const { roles } = subplebbit || {};
|
||||
const { getAddressSigner, getThreadSigner } = useAnonModeStore();
|
||||
const { anonMode } = useAnonMode(postCid);
|
||||
|
||||
const { isCommentAuthorMod, isAccountMod, isAccountCommentAuthor, commentAuthorRole, accountAuthorRole } = useMemo(() => {
|
||||
const commentAuthorRole = roles?.[commentAuthorAddress]?.role;
|
||||
const isCommentAuthorMod = commentAuthorRole === 'admin' || commentAuthorRole === 'owner' || commentAuthorRole === 'moderator';
|
||||
const accountAuthorRole = roles?.[accountAuthorAddress]?.role;
|
||||
const isAccountMod = accountAuthorRole === 'admin' || accountAuthorRole === 'owner' || accountAuthorRole === 'moderator';
|
||||
|
||||
let isAccountCommentAuthor = postCid && accountAuthorAddress === commentAuthorAddress;
|
||||
|
||||
if (!isAccountCommentAuthor && anonMode) {
|
||||
const addressSigner = getAddressSigner(commentAuthorAddress);
|
||||
const threadSigner = postCid ? getThreadSigner(postCid) : null;
|
||||
|
||||
isAccountCommentAuthor = (addressSigner && addressSigner.address === commentAuthorAddress) || (threadSigner && threadSigner.address === commentAuthorAddress);
|
||||
}
|
||||
const isAccountCommentAuthor = !!postCid && accountAuthorAddress === commentAuthorAddress;
|
||||
|
||||
return { isCommentAuthorMod, isAccountMod, isAccountCommentAuthor, commentAuthorRole, accountAuthorRole };
|
||||
}, [roles, commentAuthorAddress, accountAuthorAddress, anonMode, getAddressSigner, getThreadSigner, postCid]);
|
||||
}, [roles, commentAuthorAddress, accountAuthorAddress, postCid]);
|
||||
|
||||
return { isCommentAuthorMod, isAccountMod, isAccountCommentAuthor, commentAuthorRole, accountAuthorRole };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user