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:
@@ -1,5 +1,5 @@
|
||||
use gpui::prelude::*;
|
||||
use gpui::{Pixels, px};
|
||||
use gpui::{Pixels, px, rems};
|
||||
|
||||
use crate::theme::Theme;
|
||||
|
||||
@@ -11,6 +11,43 @@ pub const ROOT_PADDING: Pixels = px(12.0);
|
||||
pub const CONTROL_RADIUS: Pixels = px(6.0);
|
||||
pub const CONTROL_BORDER: Pixels = px(1.0);
|
||||
|
||||
pub const SIDEBAR_WIDTH: Pixels = px(250.0);
|
||||
|
||||
pub const TABLE_MAX_DESCRIPTION_LENGTH: usize = 50;
|
||||
pub const TABLE_FILTER_BAR_INITIAL_HEIGHT: Pixels = px(52.0);
|
||||
|
||||
#[inline(always)]
|
||||
pub fn table_col_id_width() -> gpui::Rems {
|
||||
rems(3.0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn table_col_desc_min_width() -> gpui::Rems {
|
||||
rems(10.0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn table_col_project_width() -> gpui::Rems {
|
||||
rems(10.0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn table_col_due_width() -> gpui::Rems {
|
||||
rems(7.0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn table_col_priority_width() -> gpui::Rems {
|
||||
rems(5.0)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn table_col_status_width() -> gpui::Rems {
|
||||
rems(6.0)
|
||||
}
|
||||
|
||||
pub const DATE_FORMAT: &str = "%Y-%m-%d";
|
||||
|
||||
pub fn card_style(div: gpui::Div, theme: &Theme) -> gpui::Div {
|
||||
div.bg(theme.card)
|
||||
.border_1()
|
||||
|
||||
Reference in New Issue
Block a user