feat(tasks): implement fallback for finding task children
This commit is contained in:
parent
8f3552aeba
commit
67a19d61f2
14
src/tasks.rs
14
src/tasks.rs
|
@ -150,19 +150,27 @@ impl Tasks {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn len(&self) -> usize { self.tasks.len() }
|
pub(crate) fn len(&self) -> usize { self.tasks.len() }
|
||||||
|
|
||||||
/// Ids of all subtasks found for id, including itself
|
/// Ids of all recursive subtasks for id, including itself
|
||||||
fn get_subtasks(&self, id: EventId) -> Vec<EventId> {
|
fn get_subtasks(&self, id: EventId) -> Vec<EventId> {
|
||||||
let mut children = Vec::with_capacity(32);
|
let mut children = Vec::with_capacity(32);
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
|
|
||||||
children.push(id);
|
children.push(id);
|
||||||
while index < children.len() {
|
while index < children.len() {
|
||||||
self.tasks.get(&children[index]).map(|t| {
|
let id = children[index];
|
||||||
|
if let Some(t) = self.tasks.get(&id) {
|
||||||
children.reserve(t.children.len());
|
children.reserve(t.children.len());
|
||||||
for child in t.children.iter() {
|
for child in t.children.iter() {
|
||||||
children.push(child.clone());
|
children.push(child.clone());
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
// Unknown task, can still find children
|
||||||
|
for task in self.tasks.values() {
|
||||||
|
if task.parent_id().is_some_and(|i| i == &id) {
|
||||||
|
children.push(task.get_id().clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue