damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 2ae4a156da6dab6d2ad065d0bb2a480daf915b46
parent f700dd799f2a5fce9ecc528f0012b6b49ec5cb20
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  6 Apr 2023 10:39:01 -0700

Make sure we only update translation cache on main thread

Diffstat:
Mdamus/Components/TranslateView.swift | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/damus/Components/TranslateView.swift b/damus/Components/TranslateView.swift @@ -74,8 +74,10 @@ struct TranslateView: View { } func failed_attempt() { - self.translated = .not_needed - damus_state.events.store_translation_artifacts(evid: event.id, translated: .not_needed) + DispatchQueue.main.async { + self.translated = .not_needed + damus_state.events.store_translation_artifacts(evid: event.id, translated: .not_needed) + } } 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) // and cache it - self.translated = .translated(Translated(artifacts: artifacts, language: note_lang)) - damus_state.events.store_translation_artifacts(evid: event.id, translated: self.translated) + DispatchQueue.main.async { + 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 {