Skip to content

Commit

Permalink
fix: show undone tasks before first toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-pitblado committed Oct 26, 2024
1 parent 4bfbcb7 commit 1354f4d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ mod app;
mod models;
mod ui;

use crate::api::fetch_tasks;

use app::App;
use crossterm::{
execute,
Expand Down Expand Up @@ -47,8 +49,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let instance_url = config.vikunja.instance_url;
let api_key = config.vikunja.api_key;

let all_tasks = api::fetch_tasks(&instance_url, &api_key, 1).await?;
let tasks_for_app = all_tasks.clone();
let show_done_tasks = false;

let tasks = fetch_tasks(&instance_url, &api_key, 1).await?;
let tasks = if show_done_tasks {
tasks
} else {
tasks.into_iter().filter(|task| !task.done).collect()
};

enable_raw_mode()?;
let mut stdout = io::stdout();
Expand All @@ -58,7 +66,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

terminal.hide_cursor()?;

let app = App::new(tasks_for_app);
let mut app = App::new(tasks);

let res = run_app(&mut terminal, app, &instance_url, &api_key).await;

Expand Down

0 comments on commit 1354f4d

Please sign in to comment.