20 lines
681 B
Rust
20 lines
681 B
Rust
use chrono::Utc;
|
|
use uuid::Uuid;
|
|
|
|
use crate::prelude::*;
|
|
|
|
use super::MainScreen;
|
|
|
|
impl MainScreen {
|
|
pub fn task_filter (self) -> impl Fn(&&Task) -> bool {
|
|
move |task: &&Task| match self {
|
|
Self::All => true,
|
|
Self::Cancelled => task.status == TaskStatus::Cancelled,
|
|
Self::Pending => task.status == TaskStatus::Pending,
|
|
Self::Done => task.status == TaskStatus::Done,
|
|
Self::Expired => task.expiring_at.is_some_and(|dt| Utc::now() > dt),
|
|
Self::Recurring => std::mem::discriminant(&task.kind) == std::mem::discriminant(&TaskKind::Recurring { parent: Uuid::default() }),
|
|
}
|
|
}
|
|
}
|