commit 58e53631c6cae241c0105cc8c78e84eaf502cf9d
parent 7b2e178f5b27297e0ba1263137fc429b0b6f9887
Author: William Casarin <jb55@jb55.com>
Date: Tue, 2 May 2023 07:50:50 -0700
Use cached note language in search model
We should never call event.note_language on the main thread
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/damus/Views/SearchHomeView.swift b/damus/Views/SearchHomeView.swift
@@ -49,8 +49,8 @@ struct SearchHomeView: View {
loading: $model.loading,
damus: damus_state,
show_friend_icon: true,
- filter: {
- if damus_state.muted_threads.isMutedThread($0, privkey: self.damus_state.keypair.privkey) {
+ filter: { ev in
+ if damus_state.muted_threads.isMutedThread(ev, privkey: self.damus_state.keypair.privkey) {
return false
}
@@ -59,11 +59,12 @@ struct SearchHomeView: View {
}
// 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 = $0.note_language(damus_state.keypair.privkey) else {
+ let note_lang = damus_state.events.get_cache_data(ev.id).translations_model.note_language
+ guard let note_lang else {
return true
}
- return preferredLanguages.contains(noteLanguage)
+ return preferredLanguages.contains(note_lang)
}
)
.refreshable {