Runs the translation as a UI Scope instead of ViewModel's

This commit is contained in:
Vitor Pamplona 2023-11-26 15:02:10 -05:00
parent 19fb129f7c
commit a2d38381b1

View File

@ -322,7 +322,8 @@ fun TranslateAndWatchLanguageChanges(content: String, accountViewModel: AccountV
val accountState by accountViewModel.accountLanguagesLiveData.observeAsState() val accountState by accountViewModel.accountLanguagesLiveData.observeAsState()
LaunchedEffect(accountState) { 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( LanguageTranslatorService.autoTranslate(
content, content,
accountViewModel.account.dontTranslateFrom, accountViewModel.account.dontTranslateFrom,