refactor(tasks): more descriptive variable names

This commit is contained in:
xeruf 2024-12-06 12:01:00 +01:00
parent 6362718aa7
commit 03fd79ad95
1 changed files with 14 additions and 14 deletions

View File

@ -79,6 +79,8 @@ pub(crate) struct TasksRelay {
search_depth: usize, search_depth: usize,
view_depth: usize, view_depth: usize,
pub(crate) recurse_activities: bool, pub(crate) recurse_activities: bool,
// Last position used in interface - needs auto-update
//position: Option<EventId>,
/// Currently active tags /// Currently active tags
tags: BTreeSet<Hashtag>, tags: BTreeSet<Hashtag>,
@ -1824,38 +1826,36 @@ mod tasks_test {
} }
macro_rules! assert_position { macro_rules! assert_position {
($left:expr, $right:expr $(,)?) => { ($tasks:expr, $id:expr $(,)?) => {
assert_eq!($left.get_position(), Some($right)) assert_eq!($tasks.get_position(), Some($id))
}; };
} }
macro_rules! assert_tasks_visible { macro_rules! assert_tasks_visible {
($left:expr, $right:expr $(,)?) => { ($tasks:expr, $expected:expr $(,)?) => {
let tasks = $left.visible_tasks(); assert_tasks!($tasks, $tasks.visible_tasks(), $expected,
assert_tasks!($left, tasks, $right,
"\nQuick Access: {:?}", "\nQuick Access: {:?}",
$left.quick_access_raw().map(|id| $left.get_relative_path(*id)).collect_vec()); $tasks.quick_access_raw().map(|id| $tasks.get_relative_path(*id)).collect_vec());
}; };
} }
macro_rules! assert_tasks_view { macro_rules! assert_tasks_view {
($left:expr, $right:expr $(,)?) => { ($tasks:expr, $expected:expr $(,)?) => {
let tasks = $left.viewed_tasks(); assert_tasks!($tasks, $tasks.viewed_tasks(), $expected, "");
assert_tasks!($left, tasks, $right, "");
}; };
} }
macro_rules! assert_tasks { macro_rules! assert_tasks {
($left:expr, $tasks:expr, $right:expr $(, $($arg:tt)*)?) => { ($tasks:expr, $tasklist:expr, $expected:expr $(, $($arg:tt)*)?) => {
assert_eq!( assert_eq!(
$tasks $tasklist
.iter() .iter()
.map(|t| t.event.id) .map(|t| t.event.id)
.collect::<HashSet<EventId>>(), .collect::<HashSet<EventId>>(),
HashSet::from_iter($right.clone()), HashSet::from_iter($expected.clone()),
"Tasks Visible: {:?}\nExpected: {:?}{}", "Tasks Visible: {:?}\nExpected: {:?}{}",
$tasks.iter().map(|t| t.event.id).map(|id| $left.get_relative_path(id)).collect_vec(), $tasklist.iter().map(|t| t.event.id).map(|id| $tasks.get_relative_path(id)).collect_vec(),
$right.into_iter().map(|id| $left.get_relative_path(id)).collect_vec(), $expected.into_iter().map(|id| $tasks.get_relative_path(id)).collect_vec(),
format!($($($arg)*)?) format!($($($arg)*)?)
); );
}; };