fix: updated cached buffer immediately

This commit is contained in:
əlemi 2023-09-05 20:40:10 +02:00
parent eeececf1b1
commit fb7f4c1b31

View file

@ -109,6 +109,7 @@ impl ControllerWorker<TextChange> for BufferControllerWorker {
match res { match res {
None => return tracing::warn!("client closed operation stream"), None => return tracing::warn!("client closed operation stream"),
Some(op) => { Some(op) => {
let _ = self.update(&op);
clientside.push_back(op.clone()); clientside.push_back(op.clone());
last_seen_tick = self.operation_tick.load(Ordering::Acquire); last_seen_tick = self.operation_tick.load(Ordering::Acquire);
} }
@ -159,7 +160,6 @@ impl ControllerWorker<TextChange> for BufferControllerWorker {
// client operation waiting for us to be enqueued // client operation waiting for us to be enqueued
if serverside.is_empty() { if serverside.is_empty() {
while let Some(op) = clientside.get(0) { while let Some(op) = clientside.get(0) {
self.update(op);
if !send_opseq(&mut tx, self.uid.clone(), self.path.clone(), op.clone()).await { break } if !send_opseq(&mut tx, self.uid.clone(), self.path.clone(), op.clone()).await { break }
clientside.pop_front(); clientside.pop_front();
} }