Skip to content

Commit

Permalink
feat: mute profile on posts
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-ext committed Dec 10, 2023
1 parent 71b780a commit 380c925
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/com/components/items/posts/PostOverflowAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,33 @@ import { openModal } from '../../../globals/modals.tsx';
import { MenuItem, MenuItemIcon, MenuRoot } from '../../../primitives/menu.ts';

import { Flyout } from '../../Flyout.tsx';
import { isProfileTempMuted, useSharedPreferences } from '../../SharedPreferences.tsx';

import DeleteIcon from '../../../icons/baseline-delete.tsx';
import LaunchIcon from '../../../icons/baseline-launch.tsx';
import ReportIcon from '../../../icons/baseline-report.tsx';
import VolumeOffIcon from '../../../icons/baseline-volume-off.tsx';

const DeletePostConfirmDialog = lazy(() => import('../../dialogs/DeletePostConfirmDialog.tsx'));
const MuteConfirmDialog = lazy(() => import('../../dialogs/MuteConfirmDialog.tsx'));

export interface PostOverflowActionProps {
post: SignalizedPost;
children: JSX.Element;
}

const PostOverflowAction = (props: PostOverflowActionProps) => {
const { filters } = useSharedPreferences();

return (() => {
const post = props.post;
const author = post.author;

const isSameAuthor = post.uid === post.author.did;

const isTempMuted = () => isProfileTempMuted(filters, author.did);
const isMuted = () => author.viewer.muted.value || isTempMuted();

if (import.meta.env.VITE_MODE === 'desktop') {
return (
<Flyout button={props.children} placement="bottom-end">
Expand Down Expand Up @@ -53,6 +62,24 @@ const PostOverflowAction = (props: PostOverflowActionProps) => {
<span>Delete post</span>
</button>
)}

{!isSameAuthor && (
<button
onClick={() => {
close();
openModal(() => <MuteConfirmDialog profile={author} filters={filters} />);
}}
class={/* @once */ MenuItem()}
>
<VolumeOffIcon class={/* @once */ MenuItemIcon()} />
<span>{isMuted() ? `Unmute @${author.handle.value}` : `Mute @${author.handle.value}`}</span>
</button>
)}

<button class={/* @once */ MenuItem()}>
<ReportIcon class={/* @once */ MenuItemIcon()} />
<span class="overflow-hidden text-ellipsis whitespace-nowrap">Report post</span>
</button>
</div>
)}
</Flyout>
Expand Down

0 comments on commit 380c925

Please sign in to comment.