commit b85be50cc4bc954c27f53905b0d924bc0835d99f
parent 39a324fd1ea5bc1081e987538cd889ed00e5b729
Author: Terry Yiu <963907+tyiu@users.noreply.github.com>
Date: Tue, 2 May 2023 14:25:09 -0400
Fix auto-translations bug where languages in preferred language still gets translated
Changelog-Fixed: Fix auto-translations bug where languages in preferred language still gets translated
Closes: #1066
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/damus/Util/EventCache.swift b/damus/Util/EventCache.swift
@@ -321,8 +321,11 @@ func get_preload_plan(evcache: EventCache, ev: NostrEvent, our_keypair: Keypair,
if load_artifacts {
cache.artifacts_model.state = .loading
}
-
- let load_translations = should_preload_translation(event: ev, our_keypair: our_keypair, current_status: cache.translations, settings: settings, note_lang: cache.translations_model.note_language)
+
+ // Cached event might not have the note language determined yet, so determine the language here before figuring out if translations should be preloaded.
+ let note_lang = cache.translations_model.note_language ?? ev.note_language(our_keypair.privkey) ?? current_language()
+
+ let load_translations = should_preload_translation(event: ev, our_keypair: our_keypair, current_status: cache.translations, settings: settings, note_lang: note_lang)
if load_translations {
cache.translations_model.state = .translating
}