feat: easy reset to own pubkey filter
This commit is contained in:
parent
e320523fc0
commit
1f13c45831
2 changed files with 18 additions and 7 deletions
|
@ -463,14 +463,13 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
Some(arg) => {
|
Some(arg) => {
|
||||||
if arg == "@" {
|
if arg == "@" {
|
||||||
info!("Showing everybody's tasks");
|
tasks.reset_key_filter()
|
||||||
tasks.set_filter_author(None)
|
|
||||||
} else if let Ok(key) = PublicKey::from_str(arg) {
|
} else if let Ok(key) = PublicKey::from_str(arg) {
|
||||||
info!("Showing {}'s tasks", tasks.get_username(&key));
|
info!("Showing {}'s tasks", tasks.get_username(&key));
|
||||||
tasks.set_filter_author(Some(key))
|
tasks.set_key_filter(key)
|
||||||
} else if let Some((key, meta)) = tasks.find_user(arg) {
|
} else if let Some((key, meta)) = tasks.find_user(arg) {
|
||||||
info!("Showing {}'s tasks", meta.display_name.as_ref().unwrap_or(meta.name.as_ref().unwrap_or(&key.to_string())));
|
info!("Showing {}'s tasks", meta.display_name.as_ref().unwrap_or(meta.name.as_ref().unwrap_or(&key.to_string())));
|
||||||
tasks.set_filter_author(Some(key.clone()))
|
tasks.set_key_filter(key.clone())
|
||||||
} else {
|
} else {
|
||||||
if parse_hour(arg, 1)
|
if parse_hour(arg, 1)
|
||||||
.or_else(|| parse_date(arg).map(|utc| utc.with_timezone(&Local)))
|
.or_else(|| parse_date(arg).map(|utc| utc.with_timezone(&Local)))
|
||||||
|
|
18
src/tasks.rs
18
src/tasks.rs
|
@ -658,8 +658,19 @@ impl TasksRelay {
|
||||||
Ok(added)
|
Ok(added)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_filter_author(&mut self, key: Option<PublicKey>) {
|
pub(crate) fn reset_key_filter(&mut self) {
|
||||||
self.pubkey = key
|
let own = self.sender.pubkey();
|
||||||
|
if self.pubkey.is_some_and(|k| k == own) {
|
||||||
|
info!("Showing everybody's tasks");
|
||||||
|
self.pubkey = None
|
||||||
|
} else {
|
||||||
|
info!("Showing own tasks");
|
||||||
|
self.pubkey = Some(own)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_key_filter(&mut self, key: PublicKey) {
|
||||||
|
self.pubkey = Some(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_filter_from(&mut self, time: Timestamp) -> bool {
|
pub(crate) fn set_filter_from(&mut self, time: Timestamp) -> bool {
|
||||||
|
@ -703,10 +714,11 @@ impl TasksRelay {
|
||||||
|
|
||||||
pub(crate) fn clear_filters(&mut self) {
|
pub(crate) fn clear_filters(&mut self) {
|
||||||
self.state = StateFilter::Default;
|
self.state = StateFilter::Default;
|
||||||
|
self.pubkey = Some(self.sender.pubkey());
|
||||||
self.view.clear();
|
self.view.clear();
|
||||||
self.tags.clear();
|
self.tags.clear();
|
||||||
self.tags_excluded.clear();
|
self.tags_excluded.clear();
|
||||||
info!("Removed all filters");
|
info!("Reset all filters");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn has_tag_filter(&self) -> bool {
|
pub(crate) fn has_tag_filter(&self) -> bool {
|
||||||
|
|
Loading…
Add table
Reference in a new issue