Try to resolve daemon hang when changing settings
This commit is contained in:
@@ -251,13 +251,15 @@ impl Daemon {
|
||||
}
|
||||
|
||||
Event::UpdateSettings(settings, reply) => {
|
||||
let previous_server_url = self.get_settings().await.unwrap_or_default().server_url;
|
||||
let previous_settings = self.get_settings().await.unwrap_or_default();
|
||||
let previous_server_url = previous_settings.server_url;
|
||||
|
||||
self.update_settings(&settings).await.unwrap_or_else(|e| {
|
||||
log::error!(target: target::SETTINGS, "Failed to update settings: {}", e);
|
||||
});
|
||||
|
||||
if previous_server_url != settings.server_url {
|
||||
// Only trigger re-sync if both URLs are Some and different, or if one is Some and other is None
|
||||
if previous_server_url.as_deref() != settings.server_url.as_deref() {
|
||||
// If the server url has changed, we'll need to do a full re-sync.
|
||||
self.delete_all_conversations().await.unwrap_or_else(|e| {
|
||||
log::error!(target: target::SYNC, "Failed to delete all conversations: {}", e);
|
||||
@@ -267,12 +269,12 @@ impl Daemon {
|
||||
self.spawn_conversation_list_sync();
|
||||
|
||||
// Also restart the update monitor.
|
||||
self.update_monitor_command_tx
|
||||
if let Err(e) = self.update_monitor_command_tx
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.send(UpdateMonitorCommand::Restart)
|
||||
.await
|
||||
.unwrap();
|
||||
.try_send(UpdateMonitorCommand::Restart) {
|
||||
log::warn!(target: target::UPDATES, "Failed to send restart command to update monitor: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
reply.send(()).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user