Revert "Refactor auto-translations and add caching"

There are quite a few issues with this and is causing crashing

This reverts commit ae82114a33.
This commit is contained in:
William Casarin
2023-03-31 10:01:31 -07:00
parent 9ba3543d91
commit f2ce146e98
12 changed files with 116 additions and 226 deletions

View File

@@ -95,11 +95,13 @@ struct NoteContentView: View {
}
}
if with_padding {
translateView
.padding(.horizontal)
} else {
translateView
if size == .selected || damus_state.settings.auto_translate {
if with_padding {
translateView
.padding(.horizontal)
} else {
translateView
}
}
if show_images && artifacts.images.count > 0 {

View File

@@ -15,6 +15,8 @@ struct SearchHomeView: View {
@State var search: String = ""
@FocusState private var isFocused: Bool
let preferredLanguages = Set(Locale.preferredLanguages.map { localeToLanguage($0) })
var SearchInput: some View {
HStack {
HStack{
@@ -52,17 +54,12 @@ struct SearchHomeView: View {
return true
}
// Always show your own posts.
if $0.pubkey == damus_state.pubkey {
return true
}
// If we can't determine the note's language with 50%+ confidence, lean on the side of caution and show it anyway.
guard let noteLanguage = damus_state.translations.detectLanguage($0, state: damus_state) else {
guard let noteLanguage = $0.note_language(damus_state.keypair.privkey) else {
return true
}
return damus_state.translations.preferredLanguages.contains(noteLanguage)
return preferredLanguages.contains(noteLanguage)
}
)
.refreshable {