From a2d38381b16fc1933f26a6392e347026b40ae106 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Sun, 26 Nov 2023 15:02:10 -0500 Subject: [PATCH] Runs the translation as a UI Scope instead of ViewModel's --- .../amethyst/ui/components/TranslatableRichTextViewer.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt b/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt index bb201d56d..b3d4e63a2 100644 --- a/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt +++ b/app/src/play/java/com/vitorpamplona/amethyst/ui/components/TranslatableRichTextViewer.kt @@ -322,7 +322,8 @@ fun TranslateAndWatchLanguageChanges(content: String, accountViewModel: AccountV val accountState by accountViewModel.accountLanguagesLiveData.observeAsState() LaunchedEffect(accountState) { - accountViewModel.runOnIO { + // This takes some time. Launches as a Composition scope to make sure this gets cancel if this item gets out of view. + launch(Dispatchers.IO) { LanguageTranslatorService.autoTranslate( content, accountViewModel.account.dontTranslateFrom,