refactor: Improve error handling and remove code duplication
Extract duplicate UI update logic from reload_tasks and handle_sync into a shared update_ui_from_tasks method. Add error notifications to StatusBar so users can see when task loading fails instead of silently showing an empty list. Fix sidebar to only show pending tasks, filtering out deleted and completed ones. Move magic numbers to constants in ui.rs (sidebar width, table column widths, date format) to make layout adjustments easier. Standardize all date formatting to ISO 8601 (YYYY-MM-DD) for consistency across the app.
This commit is contained in:
@@ -2,6 +2,8 @@ use std::collections::HashSet;
|
||||
|
||||
use chrono::NaiveDate;
|
||||
|
||||
use crate::ui::DATE_FORMAT;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct FilterState {
|
||||
pub selected_project: Option<String>,
|
||||
@@ -147,7 +149,7 @@ impl DueFilter {
|
||||
Self::Today => "Today".to_string(),
|
||||
Self::ThisWeek => "This Week".to_string(),
|
||||
Self::NoDate => "No Date".to_string(),
|
||||
Self::OnDate(date) => date.format("%d-%m-%Y").to_string(),
|
||||
Self::OnDate(date) => date.format(DATE_FORMAT).to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +160,7 @@ impl DueFilter {
|
||||
Self::Today => "today".to_string(),
|
||||
Self::ThisWeek => "this_week".to_string(),
|
||||
Self::NoDate => "none".to_string(),
|
||||
Self::OnDate(date) => format!("date:{}", date.format("%Y-%m-%d")),
|
||||
Self::OnDate(date) => format!("date:{}", date.format(DATE_FORMAT)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user