forked from janek/mostr
refactor(tasks): simplify up_to back
This commit is contained in:
parent
0c6ad19600
commit
cf04d4d852
1 changed files with 5 additions and 2 deletions
|
@ -402,8 +402,11 @@ impl TasksRelay {
|
|||
/// Move up `count` parent tasks from current position
|
||||
pub(crate) fn up_by(&self, count: usize) -> Option<EventId> {
|
||||
let pos = self.get_position();
|
||||
if count < 1 { return pos; }
|
||||
self.traverse_up_from(pos).nth(count - 1)?.parent_id().cloned()
|
||||
let mut result = pos.as_ref();
|
||||
for _ in 0..count {
|
||||
result = self.get_parent(result);
|
||||
}
|
||||
result.cloned()
|
||||
}
|
||||
|
||||
pub(crate) fn get_parent(&self, id: Option<&EventId>) -> Option<&EventId> {
|
||||
|
|
Loading…
Add table
Reference in a new issue