This commit is contained in:
Tom (plebeius.eth)
2024-06-14 18:00:48 +02:00
parent 9f43767d71
commit fcfb4b69f4
3 changed files with 24 additions and 5 deletions
@@ -1 +1 @@
export { BlockBoardButton, BlockUserButton, default } from './post-menu-desktop';
export { default } from './post-menu-desktop';
@@ -103,7 +103,7 @@ const ViewOnButton = ({ cid, isDescription, isInAllView, isInSubscriptionsView,
);
};
export const BlockUserButton = ({ address }: { address: string }) => {
const BlockUserButton = ({ address }: { address: string }) => {
const { t } = useTranslation();
const { blocked, unblock, block } = useBlock({ address });
return (
@@ -113,7 +113,7 @@ export const BlockUserButton = ({ address }: { address: string }) => {
);
};
export const BlockBoardButton = ({ address }: { address: string }) => {
const BlockBoardButton = ({ address }: { address: string }) => {
const { t } = useTranslation();
const { blocked, unblock, block } = useBlock({ address });
return (
@@ -1,14 +1,13 @@
import { useState } from 'react';
import { createPortal } from 'react-dom';
import { useTranslation } from 'react-i18next';
import { Comment } from '@plebbit/plebbit-react-hooks';
import { Comment, useBlock } from '@plebbit/plebbit-react-hooks';
import { autoUpdate, flip, FloatingFocusManager, offset, shift, useClick, useDismiss, useFloating, useId, useInteractions, useRole } from '@floating-ui/react';
import styles from './post-menu-mobile.module.css';
import { getCommentMediaInfo } from '../../../lib/utils/media-utils';
import { copyShareLinkToClipboard, isValidURL } from '../../../lib/utils/url-utils';
import useEditCommentPrivileges from '../../../hooks/use-author-privileges';
import useHide from '../../../hooks/use-hide';
import { BlockBoardButton, BlockUserButton } from '../../post-desktop/post-menu-desktop';
import EditMenu from '../../edit-menu/edit-menu';
import { isBoardView, isPostPageView } from '../../../lib/utils/view-utils';
import { useLocation, useParams } from 'react-router-dom';
@@ -87,6 +86,26 @@ const HidePostButton = ({ cid, isReply, postCid }: PostMenuMobileProps) => {
);
};
const BlockUserButton = ({ address }: { address: string }) => {
const { t } = useTranslation();
const { blocked, unblock, block } = useBlock({ address });
return (
<div className={styles.postMenuItem} onClick={blocked ? unblock : block}>
{blocked ? t('unblock_user') : t('block_user')}
</div>
);
};
const BlockBoardButton = ({ address }: { address: string }) => {
const { t } = useTranslation();
const { blocked, unblock, block } = useBlock({ address });
return (
<div className={styles.postMenuItem} onClick={blocked ? unblock : block}>
{blocked ? t('unblock_board') : t('block_board')}
</div>
);
};
const PostMenuMobile = ({ post }: { post: Comment }) => {
const { author, cid, isDescription, isRules, link, parentCid, subplebbitAddress } = post || {};
const { isCommentAuthorMod, isAccountMod, isAccountCommentAuthor } = useEditCommentPrivileges({ commentAuthorAddress: author?.address, subplebbitAddress });