diff --git a/src/gui/widgets/node_list.rs b/src/gui/widgets/node_list.rs index ef020318253f4f866e724d54ccf5be2b2db9be97..f204ea3d622dbc537ddd15083cbdf4fa0593f14e 100644 --- a/src/gui/widgets/node_list.rs +++ b/src/gui/widgets/node_list.rs @@ -1,6 +1,8 @@ use chrono::DateTime; use chrono_humanize::HumanTime; use egui_extras::{Column, TableBuilder}; +use figment::providers::Data; +use log::{error, info}; use longitude::{DistanceUnit, Location}; use meshtastic::protobufs::{channel::Role, HardwareModel, Position}; @@ -45,7 +47,15 @@ pub(crate) fn calc_distance_to_node(away: Position) -> Option<f64> { /// UI Elements for the Node List pub fn nodelist_ui(ui: &mut egui::Ui) { // Get nodes from DB - let mut nodes = Database::read_node_list().expect("Failed to read nodes"); + let mut nodes = Database::read_node_list().unwrap_or_else(|e| { + error!("Failed to read nodes: {}", e); + // Return a default value or handle the error as needed + Vec::new() // Example default value, replace with appropriate handling + }); + + info!("Loaded {} nodes from DB", nodes.len()); + + // let mut nodes = Database::read_node_list().expect("Failed to read nodes"); // Sort nodes by `last_heard` in descending order nodes.sort_by(|a, b| b.last_heard.cmp(&a.last_heard));