Skip to content

Commit

Permalink
feat: force translate post
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-ext committed Dec 27, 2023
1 parent 46c2fab commit 92a9ffd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions app/com/components/items/posts/PostOverflowAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { isProfileTempMuted, useSharedPreferences } from '../../SharedPreference
import DeleteIcon from '../../../icons/baseline-delete.tsx';
import LaunchIcon from '../../../icons/baseline-launch.tsx';
import ReportIcon from '../../../icons/baseline-report.tsx';
import TranslateIcon from '../../../icons/baseline-translate.tsx';
import VolumeOffIcon from '../../../icons/baseline-volume-off.tsx';

const DeletePostConfirmDialog = lazy(() => import('../../dialogs/DeletePostConfirmDialog.tsx'));
Expand All @@ -21,12 +22,15 @@ const ReportDialog = lazy(() => import('../../dialogs/ReportDialog.tsx'));

export interface PostOverflowActionProps {
post: SignalizedPost;
onTranslate?: () => void;
children: JSX.Element;
}

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

const onTranslate = props.onTranslate;

return (() => {
const post = props.post;
const author = post.author;
Expand All @@ -51,6 +55,19 @@ const PostOverflowAction = (props: PostOverflowActionProps) => {
<span>Open in Bluesky app</span>
</a>

{onTranslate && (
<button
onClick={() => {
close();
onTranslate();
}}
class={/* @once */ MenuItem()}
>
<TranslateIcon class={/* @once */ MenuItemIcon()} />
<span>Translate post</span>
</button>
)}

{isSameAuthor && (
<button
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion app/com/components/views/PermalinkPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const PermalinkPost = (props: PermalinkPostProps) => {
</Link>

<div class="flex shrink-0 grow justify-end">
<PostOverflowAction post={post()}>
<PostOverflowAction post={post()} onTranslate={() => setShowTl(true)}>
<button class="-mx-2 -my-1.5 flex h-8 w-8 items-center justify-center rounded-full text-base text-muted-fg hover:bg-secondary/40">
<MoreHorizIcon />
</button>
Expand Down

0 comments on commit 92a9ffd

Please sign in to comment.