show login network errors through ui

This commit is contained in:
2025-11-17 18:32:33 -05:00
parent b3c833c667
commit 09a519e5d9
3 changed files with 68 additions and 21 deletions
+8
View File
@@ -21,6 +21,7 @@ pub use app::AppHandle;
pub enum ClientEvent {
Connect { send: NetSender, username: String },
ServerMsg(ServerMsg),
Err(String),
}
pub struct Client {
@@ -34,6 +35,7 @@ pub struct Client {
dir: DataDir,
data: ClientData,
handle: AppHandle,
error: Option<WidgetId<WidgetPtr>>,
}
impl Client {
@@ -52,6 +54,7 @@ impl Client {
focus: None,
username: "<unknown>".to_string(),
clipboard: Clipboard::new().unwrap(),
error: None,
};
ui::init(&mut s);
s
@@ -80,6 +83,11 @@ impl Client {
}
}
},
ClientEvent::Err(msg) => {
if let Some(err) = &self.error {
self.ui[err].inner = Some(ui::error(&mut self.ui, &msg));
}
}
}
}