From 5b0591e0ea7de0b0fe5051d4203530fa65481517 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Sun, 8 Dec 2024 16:14:47 +0100 Subject: [PATCH] Updating the automerge doc and setting the text Co-authored-by: Alyssa Ross --- src/application.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/application.rs b/src/application.rs index 36c0900..299ce8a 100644 --- a/src/application.rs +++ b/src/application.rs @@ -27,6 +27,7 @@ use adw::subclass::prelude::*; use anyhow::Result; use automerge::transaction::Transactable; use automerge::{AutoCommit, ObjId, ObjType}; +use automerge::ReadDoc; use gettextrs::gettext; use gtk::{gio, glib}; use tokio::sync::mpsc::{Receiver, Sender}; @@ -123,9 +124,15 @@ mod imp { ); let mut rx = application.imp().rx.take().unwrap(); + let w = window.clone(); + let app = application.clone(); glib::spawn_future_local(async move { while let Some(msg) = rx.recv().await { println!("got {:?}", msg); + let mut doc = app.imp().automerge.borrow_mut(); + doc.load_incremental(&msg).unwrap(); + let text = doc.text(&app.imp().root).unwrap(); + w.set_text(&text); } });