proper reactivity on config load

This commit is contained in:
2025-10-25 19:03:02 -06:00
parent 20ec64cf1c
commit d9695be153
5 changed files with 59 additions and 54 deletions
+7 -5
View File
@@ -33,18 +33,20 @@ pub mod app;
pub mod imp;
mod msghtml;
//pub static CONFIG: Lazy<GuiConfig> = Lazy::new(|| imp::load_config().unwrap_or_default());
pub static CONFIG: async_cell::sync::AsyncCell<GuiConfig> = async_cell::sync::AsyncCell::new();
pub async fn network_entrypoint(mut event_rx: UnboundedReceiver<Command>) {
loop {
let Some(Command::Connect { address, username }) = event_rx.next().await else {
let Some(Command::Connect {
address,
username,
config,
}) = event_rx.next().await
else {
panic!("did not receive connect command")
};
*STATE.server.write() = Default::default();
*STATE.status.write() = ConnectionState::Connecting;
if let Err(error) = imp::network_connect(address, username, &mut event_rx).await {
if let Err(error) = imp::network_connect(address, username, &mut event_rx, &config).await {
error!("could not connect {:?}", error);
*STATE.status.write() = ConnectionState::Failed(error.to_string());
} else {