Make sure we only update translation cache on main thread
This commit is contained in:
@@ -74,8 +74,10 @@ struct TranslateView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func failed_attempt() {
|
func failed_attempt() {
|
||||||
self.translated = .not_needed
|
DispatchQueue.main.async {
|
||||||
damus_state.events.store_translation_artifacts(evid: event.id, translated: .not_needed)
|
self.translated = .not_needed
|
||||||
|
damus_state.events.store_translation_artifacts(evid: event.id, translated: .not_needed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func attempt_translation() async {
|
func attempt_translation() async {
|
||||||
@@ -117,8 +119,10 @@ struct TranslateView: View {
|
|||||||
let artifacts = render_blocks(blocks: translated_blocks, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey)
|
let artifacts = render_blocks(blocks: translated_blocks, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey)
|
||||||
|
|
||||||
// and cache it
|
// and cache it
|
||||||
self.translated = .translated(Translated(artifacts: artifacts, language: note_lang))
|
DispatchQueue.main.async {
|
||||||
damus_state.events.store_translation_artifacts(evid: event.id, translated: self.translated)
|
self.translated = .translated(Translated(artifacts: artifacts, language: note_lang))
|
||||||
|
damus_state.events.store_translation_artifacts(evid: event.id, translated: self.translated)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user