From 93580e5296bec5de4c58d182cd26d7bdb5f56a27 Mon Sep 17 00:00:00 2001 From: Terry Yiu <963907+tyiu@users.noreply.github.com> Date: Mon, 17 Apr 2023 01:36:46 +0200 Subject: [PATCH] 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 --- damus/Components/TranslateView.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/damus/Components/TranslateView.swift b/damus/Components/TranslateView.swift index 7c81ecbb..31430c12 100644 --- a/damus/Components/TranslateView.swift +++ b/damus/Components/TranslateView.swift @@ -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