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
This commit is contained in:
Vendicated 2024-02-06 17:04:01 +01:00
parent 2c198e547c
commit e58aa5dbab
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
3 changed files with 26 additions and 4 deletions

View file

@ -80,8 +80,6 @@ const buttonFactories = new Map<string, ChatBarButton>();
const logger = new Logger("ChatButtons"); const logger = new Logger("ChatButtons");
export function _injectButtons(buttons: ReactNode[], props: ChatBarProps) { export function _injectButtons(buttons: ReactNode[], props: ChatBarProps) {
if (props.type.analyticsName !== "normal") return;
for (const [key, makeButton] of buttonFactories) { for (const [key, makeButton] of buttonFactories) {
try { try {
const res = makeButton(props, props.type.analyticsName === "normal"); const res = makeButton(props, props.type.analyticsName === "normal");

View file

@ -17,8 +17,10 @@
*/ */
import { ChatBarButton } from "@api/ChatButtons"; import { ChatBarButton } from "@api/ChatButtons";
import { Margins } from "@utils/margins";
import { classes } from "@utils/misc"; import { classes } from "@utils/misc";
import { openModal } from "@utils/modal"; import { openModal } from "@utils/modal";
import { Alerts, Forms } from "@webpack/common";
import { settings } from "./settings"; import { settings } from "./settings";
import { TranslateModal } from "./TranslateModal"; import { TranslateModal } from "./TranslateModal";
@ -42,7 +44,27 @@ export const TranslateChatBarIcon: ChatBarButton = (props, isMainChat) => {
if (!isMainChat) return null; 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: <>
<Forms.FormText>
You just enabled auto translate (by right clicking the Translate icon). Any message you send will automatically be translated before being sent.
</Forms.FormText>
<Forms.FormText className={Margins.top16}>
If this was an accident, disable it again, or it will change your message content before sending.
</Forms.FormText>
</>,
cancelText: "Disable Auto-Translate",
confirmText: "Got it",
secondaryConfirmText: "Don't show again",
onConfirmSecondary: () => settings.store.showAutoTranslateAlert = false,
onCancel: () => settings.store.autoTranslate = false
});
};
return ( return (
<ChatBarButton <ChatBarButton

View file

@ -49,4 +49,6 @@ export const settings = definePluginSettings({
description: "Automatically translate your messages before sending. You can also shift/right click the translate button to toggle this", description: "Automatically translate your messages before sending. You can also shift/right click the translate button to toggle this",
default: false default: false
} }
}); }).withPrivateSettings<{
showAutoTranslateAlert: boolean;
}>();