Private
Public Access
1
0

daemon: update monitor: implements ping/pong (required server changes)

This commit is contained in:
2025-06-13 16:45:28 -07:00
parent 4f40be205d
commit dece6f1abc
12 changed files with 202 additions and 55 deletions

View File

@@ -163,6 +163,17 @@ impl Daemon {
}
}
fn spawn_conversation_list_sync(&mut self) {
let mut db_clone = self.database.clone();
let signal_sender = self.signal_sender.clone();
self.runtime.spawn(async move {
let result = Self::sync_conversation_list(&mut db_clone, &signal_sender).await;
if let Err(e) = result {
log::error!(target: target::SYNC, "Error handling sync event: {}", e);
}
});
}
async fn handle_event(&mut self, event: Event) {
match event {
Event::GetVersion(reply) => {
@@ -170,14 +181,7 @@ impl Daemon {
}
Event::SyncConversationList(reply) => {
let mut db_clone = self.database.clone();
let signal_sender = self.signal_sender.clone();
self.runtime.spawn(async move {
let result = Self::sync_conversation_list(&mut db_clone, &signal_sender).await;
if let Err(e) = result {
log::error!(target: target::SYNC, "Error handling sync event: {}", e);
}
});
self.spawn_conversation_list_sync();
// This is a background operation, so return right away.
reply.send(()).unwrap();
@@ -216,6 +220,19 @@ impl Daemon {
reply.send(()).unwrap();
}
Event::UpdateStreamReconnected => {
log::info!(target: target::UPDATES, "Update stream reconnected");
// The ui client will respond differently, but we'll almost certainly want to do a sync-list in response to this.
self.spawn_conversation_list_sync();
// Send signal to the client that the update stream has been reconnected.
self.signal_sender
.send(Signal::UpdateStreamReconnected)
.await
.unwrap();
}
Event::GetAllConversations(limit, offset, reply) => {
let conversations = self.get_conversations_limit_offset(limit, offset).await;
reply.send(conversations).unwrap();