mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Move thread to start_background_thread function
This commit is contained in:
parent
a7b4f424e3
commit
953ec46e74
1 changed files with 34 additions and 32 deletions
14
src/app.rs
14
src/app.rs
|
@ -126,9 +126,13 @@ impl TTApp {
|
||||||
colors: TColor::default(),
|
colors: TColor::default(),
|
||||||
};
|
};
|
||||||
app.update();
|
app.update();
|
||||||
let handle = {
|
app.start_background_thread();
|
||||||
let tasks = app.tasks.clone();
|
app
|
||||||
let filter = app.filter.clone();
|
}
|
||||||
|
|
||||||
|
pub fn start_background_thread(&self) {
|
||||||
|
let tasks = self.tasks.clone();
|
||||||
|
let filter = self.filter.clone();
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
let mut task = Command::new("task");
|
let mut task = Command::new("task");
|
||||||
|
|
||||||
|
@ -156,9 +160,7 @@ impl TTApp {
|
||||||
tasks.lock().unwrap().sort_by(cmp);
|
tasks.lock().unwrap().sort_by(cmp);
|
||||||
}
|
}
|
||||||
thread::sleep(Duration::from_millis(250));
|
thread::sleep(Duration::from_millis(250));
|
||||||
})
|
});
|
||||||
};
|
|
||||||
app
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw(&mut self, f: &mut Frame<impl Backend>) {
|
pub fn draw(&mut self, f: &mut Frame<impl Backend>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue