forked from janek/mostr
refactor(tasks): accurately rename referenced_events to singular
This commit is contained in:
parent
d1ae0f5458
commit
018357b21e
13
src/tasks.rs
13
src/tasks.rs
|
@ -163,7 +163,7 @@ impl Tasks {
|
||||||
.filter(|e| e.created_at <= timestamp)
|
.filter(|e| e.created_at <= timestamp)
|
||||||
.map_or_else(
|
.map_or_else(
|
||||||
|| (Timestamp::now(), None),
|
|| (Timestamp::now(), None),
|
||||||
|e| (e.created_at, referenced_events(e)))
|
|e| (e.created_at, referenced_event(e)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ids of all subtasks recursively found for id, including itself
|
/// Ids of all subtasks recursively found for id, including itself
|
||||||
|
@ -869,18 +869,19 @@ impl Tasks {
|
||||||
pub(crate) fn move_back_to(&mut self, str: &str) -> bool {
|
pub(crate) fn move_back_to(&mut self, str: &str) -> bool {
|
||||||
let lower = str.to_ascii_lowercase();
|
let lower = str.to_ascii_lowercase();
|
||||||
let found = self.history_before_now()
|
let found = self.history_before_now()
|
||||||
.find(|e| referenced_events(e)
|
.find(|e| referenced_event(e)
|
||||||
.and_then(|id| self.get_by_id(id))
|
.and_then(|id| self.get_by_id(id))
|
||||||
.is_some_and(|t| t.event.content.to_ascii_lowercase().contains(&lower)));
|
.is_some_and(|t| t.event.content.to_ascii_lowercase().contains(&lower)));
|
||||||
if let Some(event) = found {
|
if let Some(event) = found {
|
||||||
self.move_to(referenced_events(event).cloned());
|
self.move_to(referenced_event(event).cloned());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn move_back_by(&mut self, steps: usize) {
|
pub(crate) fn move_back_by(&mut self, steps: usize) {
|
||||||
let id = self.history_before_now().nth(steps).and_then(|e| referenced_events(e));
|
let id = self.history_before_now().nth(steps)
|
||||||
|
.and_then(|e| referenced_event(e));
|
||||||
self.move_to(id.cloned())
|
self.move_to(id.cloned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -897,7 +898,7 @@ impl Tasks {
|
||||||
self.tasks.remove(&event.id);
|
self.tasks.remove(&event.id);
|
||||||
self.history.get_mut(&self.sender.pubkey())
|
self.history.get_mut(&self.sender.pubkey())
|
||||||
.map(|t| t.retain(|t, e| e != event &&
|
.map(|t| t.retain(|t, e| e != event &&
|
||||||
!referenced_events(e).is_some_and(|id| id == &event.id)));
|
!referenced_event(e).is_some_and(|id| id == &event.id)));
|
||||||
self.referenced_tasks(event, |t| { t.props.remove(event); });
|
self.referenced_tasks(event, |t| { t.props.remove(event); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1038,7 +1039,7 @@ pub(crate) fn join_tasks<'a>(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn referenced_events(event: &Event) -> Option<&EventId> {
|
fn referenced_event(event: &Event) -> Option<&EventId> {
|
||||||
event.tags.iter().find_map(|tag| match tag.as_standardized() {
|
event.tags.iter().find_map(|tag| match tag.as_standardized() {
|
||||||
Some(TagStandard::Event { event_id, .. }) => Some(event_id),
|
Some(TagStandard::Event { event_id, .. }) => Some(event_id),
|
||||||
_ => None
|
_ => None
|
||||||
|
|
Loading…
Reference in New Issue