feat(catalog): add catalog post previews

This commit is contained in:
Tom (plebeius.eth)
2024-06-08 11:27:29 +02:00
parent 0b2f02cd91
commit 88dcfcaca8
9 changed files with 249 additions and 44 deletions
+21
View File
@@ -0,0 +1,21 @@
import { useAccount, useSubplebbit } from '@plebbit/plebbit-react-hooks';
interface AuthorPrivilegesProps {
commentAuthorAddress: string;
subplebbitAddress: string;
}
const useAuthorPrivileges = ({ commentAuthorAddress, subplebbitAddress }: AuthorPrivilegesProps) => {
const accountAuthorAddress = useAccount()?.author?.address;
const { roles } = useSubplebbit({ subplebbitAddress }) || {};
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';
const isAccountCommentAuthor = accountAuthorAddress === commentAuthorAddress;
return { isCommentAuthorMod, isAccountMod, isAccountCommentAuthor, commentAuthorRole, accountAuthorRole };
};
export default useAuthorPrivileges;