From 894c6a52cdf99eb69e8511f9707c4ce2761ddcc1 Mon Sep 17 00:00:00 2001 From: Rico040 <93081680+Rico040@users.noreply.github.com> Date: Sun, 2 Jun 2024 19:37:43 +1000 Subject: [PATCH] various fixes for dislate lite - case unsenitify search bar on languages page - fix my stupid mistakes caused bu gigacode (fuck gigacode, i hate gigacode autocomplition) - fix clyde ephemeral message being unclosable (i hope) --- plugins/dislate/src/api/GTranslate.ts | 2 -- plugins/dislate/src/patches/ActionSheet.tsx | 4 ++-- plugins/dislate/src/patches/Commands.tsx | 20 ++++++++++++-------- plugins/dislate/src/settings/TargetLang.tsx | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/dislate/src/api/GTranslate.ts b/plugins/dislate/src/api/GTranslate.ts index 186ab0b..c827d91 100644 --- a/plugins/dislate/src/api/GTranslate.ts +++ b/plugins/dislate/src/api/GTranslate.ts @@ -17,8 +17,6 @@ const translate = async (text: string, source_lang: string = "auto", target_lang const data: GTranslateResponse = await (await fetch(API_URL)).json() - console.log(data) - return { source_lang, text: data.sentences.map(s => s.trans).join('') } diff --git a/plugins/dislate/src/patches/ActionSheet.tsx b/plugins/dislate/src/patches/ActionSheet.tsx index 1610f7e..98372c8 100644 --- a/plugins/dislate/src/patches/ActionSheet.tsx +++ b/plugins/dislate/src/patches/ActionSheet.tsx @@ -59,10 +59,10 @@ export default () => before("openLazy", LazyActionSheet, ([component, key, msg]) switch(settings.translator) { case 0: console.log("Translating with DeepL: ", originalMessage.content) - translate = await DeepL.translate(originalMessage.content, null, target_lang, !isTranslated) + translate = await DeepL.translate(originalMessage.content, undefined, target_lang, !isTranslated) case 1: console.log("Translating with GTranslate: ", originalMessage.content) - translate = await GTranslate.translate(originalMessage.content, null, target_lang, !isTranslated) + translate = await GTranslate.translate(originalMessage.content, undefined, target_lang, !isTranslated) } FluxDispatcher.dispatch({ diff --git a/plugins/dislate/src/patches/Commands.tsx b/plugins/dislate/src/patches/Commands.tsx index 132fc92..560c0f5 100644 --- a/plugins/dislate/src/patches/Commands.tsx +++ b/plugins/dislate/src/patches/Commands.tsx @@ -17,11 +17,15 @@ const langOptionsDeepL = Object.entries(DeepLLangs).map(([key, value]) => ({ displayName: key, value: value })) -const langOptionsGTranslate = Object.entries(GTranslate).map(([key, value]) => ({ - name: key, - displayName: key, - value: value -})) + +// TODO: Make command option somehow vary with different translators +// const langOptionsGTranslate = Object.entries(GTranslate).map(([key, value]) => ({ +// name: key, +// displayName: key, +// value: value +// })) +// const langOptions = settings?.translator === 1 ? langOptionsGTranslate : langOptionsDeepL; + export default () => registerCommand({ name: "translate", displayName: "translate", @@ -56,9 +60,9 @@ export default () => registerCommand({ var content switch(settings.translator) { case 0: - content = await DeepL.translate(text.value, null, lang.value) + content = await DeepL.translate(text.value, undefined, lang.value) case 1: - content = await GTranslate.translate(text.value, null, lang.value) + content = await GTranslate.translate(text.value, undefined, lang.value) } return await new Promise((resolve): void => showConfirmationAlert({ title: "Are you sure you want to send it?", @@ -73,7 +77,7 @@ export default () => registerCommand({ })) } catch (e) { logger.error(e) - return ClydeUtils.sendBotMessage(ctx.channel.id, "Failed to translate message. Please check Debug Logs for more info.", getAssetIDByName("Small")) + return ClydeUtils.sendBotMessage(ctx.channel.id, "Failed to translate message. Please check Debug Logs for more info.") } } }) \ No newline at end of file diff --git a/plugins/dislate/src/settings/TargetLang.tsx b/plugins/dislate/src/settings/TargetLang.tsx index 3f2a6de..5853d60 100644 --- a/plugins/dislate/src/settings/TargetLang.tsx +++ b/plugins/dislate/src/settings/TargetLang.tsx @@ -22,7 +22,7 @@ export default () => { }} /> { - Object.entries(DeepLLangs).filter(([key, value]) => key.includes(query)).map(([key, value]) => key.toLowerCase().includes(query.toLowerCase())).map(([key, value]) => } onPress={() => { @@ -43,7 +43,7 @@ export default () => { }} /> { - Object.entries(GTranslateLangs).filter(([key, value]) => key.includes(query)).map(([key, value]) => key.toLowerCase().includes(query.toLowerCase())).map(([key, value]) => } onPress={() => {