forked from janek/mostr
1
0
Fork 0

fix(tasks): hide duplicates again in personal time-tracking history

This commit is contained in:
xeruf 2024-08-19 17:35:26 +03:00
parent 3b9fedd9a3
commit 721c200b97
1 changed files with 4 additions and 2 deletions

View File

@ -179,15 +179,17 @@ impl Tasks {
match self.get_position_ref() { match self.get_position_ref() {
None => { None => {
if let Some(set) = self.history.get(&self.sender.pubkey()) { if let Some(set) = self.history.get(&self.sender.pubkey()) {
let mut last = None;
let mut full = Vec::with_capacity(set.len()); let mut full = Vec::with_capacity(set.len());
for event in set { for event in set {
let new = some_non_empty(&event.tags.iter() let new = some_non_empty(&event.tags.iter()
.filter_map(|t| t.content()) .filter_map(|t| t.content())
.map(|str| EventId::from_str(str).ok().map_or(str.to_string(), |id| self.get_task_title(&id))) .map(|str| EventId::from_str(str).ok().map_or(str.to_string(), |id| self.get_task_title(&id)))
.join(" ")); .join(" "));
if new.as_ref() != full.last() { if new != last {
// TODO alternating color for days // TODO alternate color with grey between days
full.push(format!("{:>15} {}", relative_datetimestamp(&event.created_at), new.as_ref().unwrap_or(&"---".to_string()))); full.push(format!("{:>15} {}", relative_datetimestamp(&event.created_at), new.as_ref().unwrap_or(&"---".to_string())));
last = new;
} }
} }
("Your Time-Tracking History:".to_string(), Box::from(full.into_iter())) ("Your Time-Tracking History:".to_string(), Box::from(full.into_iter()))