From 34b6525b375ed80e9b1b0a3a80eeff9e8a12a7d8 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 22 Jan 2023 10:24:19 +0100 Subject: [PATCH] Fix translation on RT --- Packages/Status/Sources/Status/Row/StatusRowView.swift | 2 +- Packages/Status/Sources/Status/Row/StatusRowViewModel.swift | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Packages/Status/Sources/Status/Row/StatusRowView.swift b/Packages/Status/Sources/Status/Row/StatusRowView.swift index 3a6676fb..0fb7e6b5 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowView.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowView.swift @@ -309,7 +309,7 @@ public struct StatusRowView: View { } } - if let translation = viewModel.translation { + if let translation = viewModel.translation, !viewModel.isLoadingTranslation { GroupBox { VStack(alignment: .leading, spacing: 4) { Text(translation) diff --git a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift index c7886dc2..e7c302e2 100644 --- a/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift +++ b/Packages/Status/Sources/Status/Row/StatusRowViewModel.swift @@ -230,10 +230,12 @@ public class StatusRowViewModel: ObservableObject { withAnimation { isLoadingTranslation = true } - let translation = try await client.request(target: userLang, source: status.language, text: status.content.asRawText) + let translation = try await client.request(target: userLang, + source: status.language, + text: status.reblog?.content.asRawText ?? status.content.asRawText) withAnimation { - isLoadingTranslation = false self.translation = translation + isLoadingTranslation = false } } catch {} }