From aeefdeaaff2fe9e5fbb412521ed25e25a313caf8 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Sun, 12 May 2024 22:01:17 -0400 Subject: [PATCH] fix: Deprecation warning --- src/app.rs | 6 +++--- src/pane/context.rs | 6 +++--- src/pane/project.rs | 6 +++--- src/table.rs | 14 +++++++------- src/task_report.rs | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/app.rs b/src/app.rs index 854487a6..204a03f2 100644 --- a/src/app.rs +++ b/src/app.rs @@ -55,7 +55,7 @@ use crate::{ Pane, }, scrollbar::Scrollbar, - table::{Row, Table, TableMode, TableState}, + table::{Row, Table, TableMode, TaskwarriorTuiTableState}, task_report::TaskReportTable, ui, utils, }; @@ -167,7 +167,7 @@ pub enum Mode { pub struct TaskwarriorTui { pub should_quit: bool, pub dirty: bool, - pub task_table_state: TableState, + pub task_table_state: TaskwarriorTuiTableState, pub current_context_filter: String, pub current_context: String, pub command: LineBuffer, @@ -254,7 +254,7 @@ impl TaskwarriorTui { let mut app = Self { should_quit: false, dirty: true, - task_table_state: TableState::default(), + task_table_state: TaskwarriorTuiTableState::default(), tasks: vec![], all_tasks: vec![], task_details: HashMap::new(), diff --git a/src/pane/context.rs b/src/pane/context.rs index 07a5daf7..76ac5d43 100644 --- a/src/pane/context.rs +++ b/src/pane/context.rs @@ -32,7 +32,7 @@ use crate::{ app::{Mode, TaskwarriorTui}, event::KeyCode, pane::Pane, - table::TableState, + table::TaskwarriorTuiTableState, }; #[derive(Debug, Clone, Default)] @@ -55,7 +55,7 @@ impl ContextDetails { } pub struct ContextsState { - pub table_state: TableState, + pub table_state: TaskwarriorTuiTableState, pub report_height: u16, pub columns: Vec, pub rows: Vec, @@ -64,7 +64,7 @@ pub struct ContextsState { impl ContextsState { pub(crate) fn new() -> Self { Self { - table_state: TableState::default(), + table_state: TaskwarriorTuiTableState::default(), report_height: 0, columns: vec![NAME.to_string(), TYPE.to_string(), DEFINITION.to_string(), ACTIVE.to_string()], rows: vec![], diff --git a/src/pane/project.rs b/src/pane/project.rs index 5e379067..12a4cc84 100644 --- a/src/pane/project.rs +++ b/src/pane/project.rs @@ -32,13 +32,13 @@ use crate::{ app::{Mode, TaskwarriorTui}, event::KeyCode, pane::Pane, - table::TableState, + table::TaskwarriorTuiTableState, utils::Changeset, }; pub struct ProjectsState { pub(crate) list: Vec, - pub table_state: TableState, + pub table_state: TaskwarriorTuiTableState, pub current_selection: usize, pub marked: HashSet, pub columns: Vec, @@ -58,7 +58,7 @@ impl ProjectsState { pub(crate) fn new() -> Self { Self { list: Vec::default(), - table_state: TableState::default(), + table_state: TaskwarriorTuiTableState::default(), current_selection: 0, marked: HashSet::default(), columns: vec![ diff --git a/src/table.rs b/src/table.rs index 52ecb154..9ac5981d 100644 --- a/src/table.rs +++ b/src/table.rs @@ -25,16 +25,16 @@ pub enum TableMode { } #[derive(Clone)] -pub struct TableState { +pub struct TaskwarriorTuiTableState { offset: usize, current_selection: Option, marked: HashSet, mode: TableMode, } -impl Default for TableState { - fn default() -> TableState { - TableState { +impl Default for TaskwarriorTuiTableState { + fn default() -> TaskwarriorTuiTableState { + TaskwarriorTuiTableState { offset: 0, current_selection: Some(0), marked: HashSet::new(), @@ -43,7 +43,7 @@ impl Default for TableState { } } -impl TableState { +impl TaskwarriorTuiTableState { pub fn mode(&self) -> TableMode { self.mode.clone() } @@ -305,7 +305,7 @@ where D::Item: Display, R: Iterator>, { - type State = TableState; + type State = TaskwarriorTuiTableState; fn render(mut self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { buf.set_style(area, self.style); @@ -530,7 +530,7 @@ where R: Iterator>, { fn render(self, area: Rect, buf: &mut Buffer) { - let mut state = TableState::default(); + let mut state = TaskwarriorTuiTableState::default(); StatefulWidget::render(self, area, buf, &mut state); } } diff --git a/src/task_report.rs b/src/task_report.rs index 8f20e735..74fb0eef 100644 --- a/src/task_report.rs +++ b/src/task_report.rs @@ -14,7 +14,7 @@ pub fn format_date_time(dt: NaiveDateTime) -> String { pub fn format_date(dt: NaiveDateTime) -> String { let offset = Local.offset_from_utc_datetime(&dt); - let dt = DateTime::::from_utc(dt, offset); + let dt = DateTime::::from_naive_utc_and_offset(dt, offset); dt.format("%Y-%m-%d").to_string() }