proper reactivity on config load
This commit is contained in:
+7
-5
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user