From e8d6602ae16ddb8b15f7cab84bb28459abe68639 Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Sun, 14 Jul 2024 10:22:40 +0200 Subject: [PATCH] better error display --- jiji.project | 2 +- src/app.rs | 1 + src/main.rs | 2 ++ src/ui.rs | 13 +++++++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/jiji.project b/jiji.project index f6fd60b..20edb60 100644 --- a/jiji.project +++ b/jiji.project @@ -1 +1 @@ -{"categories":[{"name":"to do","content":[{"name":"ability to change token","description":"use a config file to store token so that \n\n1- it is away from github\n\n2- it is configurable if need be","id":1},{"name":"clean up bot code","description":"try to remove unnecessary code\n\nunindent\n\ngive sender to function ?","id":2},{"name":"trayable ?","description":"// Hello there","id":5},{"name":"new message marker","description":"perma if too complicated to detect read","id":2},{"name":"proper links","description":"when there is a link, ability to click it","id":3}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"run discord bot","description":"make it so the bot is running","id":1},{"name":"fixed token in github","description":"// Hello there","id":1},{"name":"fetch previous messages","description":"// Hello there","id":4},{"name":"ability to write messages","description":"// Hello there","id":5},{"name":"get incoming messages","description":"read","id":2},{"name":"unread system","description":"add a * when a channel just received a message","id":1},{"name":"remember channel id for dm","description":"and put in config file\n\nmaybe load message ? dm first ?","id":3},{"name":"bug : does not save notification state for dm","description":"// Hello there","id":1},{"name":"handle unknown channel better","description":"when receiving a message from a not yet scanned guild, create the channel and put the message\n\nallow scanning if guild selected\n\ndo not add duplicate channel","id":1},{"name":"guild unread ?","description":"// Hello there","id":2}]},{"name":"bugs","content":[]},{"name":"v1.0","content":[{"name":"better ui error display","description":"handle the error packet for better display","id":1},{"name":"notifications !!!","description":"// Hello there","id":4},{"name":"timestamps","description":"// Hello there","id":1}]},{"name":"+","content":[]}]} \ No newline at end of file +{"categories":[{"name":"to do","content":[{"name":"ability to change token","description":"use a config file to store token so that \n\n1- it is away from github\n\n2- it is configurable if need be","id":1},{"name":"clean up bot code","description":"try to remove unnecessary code\n\nunindent\n\ngive sender to function ?","id":2},{"name":"trayable ?","description":"// Hello there","id":5},{"name":"new message marker","description":"perma if too complicated to detect read","id":2},{"name":"proper links","description":"when there is a link, ability to click it","id":3}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"run discord bot","description":"make it so the bot is running","id":1},{"name":"fixed token in github","description":"// Hello there","id":1},{"name":"fetch previous messages","description":"// Hello there","id":4},{"name":"ability to write messages","description":"// Hello there","id":5},{"name":"get incoming messages","description":"read","id":2},{"name":"unread system","description":"add a * when a channel just received a message","id":1},{"name":"remember channel id for dm","description":"and put in config file\n\nmaybe load message ? dm first ?","id":3},{"name":"bug : does not save notification state for dm","description":"// Hello there","id":1},{"name":"handle unknown channel better","description":"when receiving a message from a not yet scanned guild, create the channel and put the message\n\nallow scanning if guild selected\n\ndo not add duplicate channel","id":1},{"name":"guild unread ?","description":"// Hello there","id":2},{"name":"timestamps","description":"// Hello there","id":1}]},{"name":"bugs","content":[]},{"name":"v1.0","content":[{"name":"better ui error display","description":"handle the error packet for better display","id":1},{"name":"notifications !!!","description":"// Hello there","id":4}]},{"name":"+","content":[]}]} \ No newline at end of file diff --git a/src/app.rs b/src/app.rs index 0d1c765..b241453 100644 --- a/src/app.rs +++ b/src/app.rs @@ -99,6 +99,7 @@ impl Jiji { } postman::Packet::Error(reason) => { println!("app : error received {}", reason); + self.errors.push(reason); } postman::Packet::FinishedRequest => { self.pending_bot_requests = self.pending_bot_requests.checked_sub(1).unwrap_or(0); diff --git a/src/main.rs b/src/main.rs index 26a9992..85b8b1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,6 +56,7 @@ struct Jiji { pending_bot_requests: usize, current_message: String, channels_to_notify: Vec, + errors: Vec, } impl Jiji { @@ -88,6 +89,7 @@ impl Jiji { pending_bot_requests: 0, current_message: "".into(), channels_to_notify: app_state.channels_to_notify.clone(), + errors: vec![], } } } diff --git a/src/ui.rs b/src/ui.rs index 7330529..6faf09a 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -9,6 +9,19 @@ impl Jiji { egui::TopBottomPanel::top("server_selection") .resizable(false) .show(ctx, |ui| { + let mut delete_error: Option = None; + for i in 0..self.errors.len() { + ui.horizontal(|ui| { + if ui.button("X").clicked() { + delete_error = Some(i); + } + ui.colored_label(hex_str_to_color("#dd5d5a"), &self.errors[i]); + }); + } + + if let Some(index) = delete_error { + self.errors.remove(index); + } ui.horizontal(|ui| { ui.label("Where do you want to look ? "); let selected_guild_text = if let Some(selected_guild_index) = &self.selected_guild {