Skip to content

Commit

Permalink
Updating the automerge doc and setting the text
Browse files Browse the repository at this point in the history
Co-authored-by: Alyssa Ross <[email protected]>
  • Loading branch information
swick and alyssais committed Dec 8, 2024
1 parent 4b31c41 commit 5b0591e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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);
}
});

Expand Down

0 comments on commit 5b0591e

Please sign in to comment.