Do not translate own notes if logged in with private key

If you're not the private key user, it's possible you're just lurking on
somebody's account and you might not speak their language, so you might
need translations.

Changelog-Fixed: Do not translate own notes if logged in with private key
Closes: #943
This commit is contained in:
2023-04-17 01:36:46 +02:00
committed by William Casarin
parent a5c33e4431
commit 93580e5296

View File

@@ -40,8 +40,14 @@ struct TranslateView: View {
} else {
self.currentLanguage = Locale.current.languageCode ?? "en"
}
if let cached = damus_state.events.lookup_translated_artifacts(evid: event.id) {
if damus_state.pubkey == event.pubkey && damus_state.is_privkey_user {
// Do not translate self-authored notes if logged in with a private key
// as we can assume the user can understand their own notes.
// The detected language prediction could be incorrect and not in the list of preferred languages.
// Offering a translation in this case is definitely incorrect so let's avoid it altogether.
self._translated = State(initialValue: .not_needed)
} else if let cached = damus_state.events.lookup_translated_artifacts(evid: event.id) {
self._translated = State(initialValue: cached)
} else {
let initval: TranslateStatus = self.damus_state.settings.auto_translate ? .trying : .havent_tried