From e58aa5dbab5dd1fdf911a3e8619905cd0df7654a Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 6 Feb 2024 17:04:01 +0100 Subject: [PATCH] Translate: Add auto translate enable alert somehow people accidently enable it then get confused why vencord has "auto correct". this should hopefully solve the issue --- src/api/ChatButtons.tsx | 2 -- src/plugins/translate/TranslateIcon.tsx | 24 +++++++++++++++++++++++- src/plugins/translate/settings.ts | 4 +++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/api/ChatButtons.tsx b/src/api/ChatButtons.tsx index c995033b..3cef250b 100644 --- a/src/api/ChatButtons.tsx +++ b/src/api/ChatButtons.tsx @@ -80,8 +80,6 @@ const buttonFactories = new Map(); const logger = new Logger("ChatButtons"); export function _injectButtons(buttons: ReactNode[], props: ChatBarProps) { - if (props.type.analyticsName !== "normal") return; - for (const [key, makeButton] of buttonFactories) { try { const res = makeButton(props, props.type.analyticsName === "normal"); diff --git a/src/plugins/translate/TranslateIcon.tsx b/src/plugins/translate/TranslateIcon.tsx index a7d78927..7371f78b 100644 --- a/src/plugins/translate/TranslateIcon.tsx +++ b/src/plugins/translate/TranslateIcon.tsx @@ -17,8 +17,10 @@ */ import { ChatBarButton } from "@api/ChatButtons"; +import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { openModal } from "@utils/modal"; +import { Alerts, Forms } from "@webpack/common"; import { settings } from "./settings"; import { TranslateModal } from "./TranslateModal"; @@ -42,7 +44,27 @@ export const TranslateChatBarIcon: ChatBarButton = (props, isMainChat) => { if (!isMainChat) return null; - const toggle = () => settings.store.autoTranslate = !autoTranslate; + const toggle = () => { + const newState = !autoTranslate; + settings.store.autoTranslate = newState; + if (newState && settings.store.showAutoTranslateAlert !== false) + Alerts.show({ + title: "Vencord Auto-Translate Enabled", + body: <> + + You just enabled auto translate (by right clicking the Translate icon). Any message you send will automatically be translated before being sent. + + + If this was an accident, disable it again, or it will change your message content before sending. + + , + cancelText: "Disable Auto-Translate", + confirmText: "Got it", + secondaryConfirmText: "Don't show again", + onConfirmSecondary: () => settings.store.showAutoTranslateAlert = false, + onCancel: () => settings.store.autoTranslate = false + }); + }; return ( ();