Compare commits
2 Commits
c3d18e4494
...
84e46827ce
Author | SHA1 | Date |
---|---|---|
xeruf | 84e46827ce | |
xeruf | 3c93e0aae7 |
|
@ -5,6 +5,8 @@ use chrono::LocalResult::Single;
|
||||||
use log::{debug, error, info, trace, warn};
|
use log::{debug, error, info, trace, warn};
|
||||||
use nostr_sdk::Timestamp;
|
use nostr_sdk::Timestamp;
|
||||||
|
|
||||||
|
pub const CHARACTER_THRESHOLD: usize = 3;
|
||||||
|
|
||||||
pub fn some_non_empty(str: &str) -> Option<String> {
|
pub fn some_non_empty(str: &str) -> Option<String> {
|
||||||
if str.is_empty() { None } else { Some(str.to_string()) }
|
if str.is_empty() { None } else { Some(str.to_string()) }
|
||||||
}
|
}
|
||||||
|
@ -33,7 +35,7 @@ pub fn parse_date(str: &str) -> Option<DateTime<Utc>> {
|
||||||
match parse_datetime::parse_datetime_at_date(Local::now(), str) {
|
match parse_datetime::parse_datetime_at_date(Local::now(), str) {
|
||||||
Ok(date) => Some(date.to_utc()),
|
Ok(date) => Some(date.to_utc()),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
warn!("Could not parse date from {str}: {e}");
|
warn!("Could not parse date from \"{str}\": {e}");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,7 +415,13 @@ async fn main() -> Result<()> {
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Some(arg) => tasks.make_note(arg),
|
Some(arg) => {
|
||||||
|
if arg.len() < CHARACTER_THRESHOLD {
|
||||||
|
warn!("Note needs at least {CHARACTER_THRESHOLD} characters!");
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
tasks.make_note(arg)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
Some('>') => {
|
Some('>') => {
|
||||||
|
|
15
src/tasks.rs
15
src/tasks.rs
|
@ -14,7 +14,7 @@ use nostr_sdk::prelude::Marker;
|
||||||
use TagStandard::Hashtag;
|
use TagStandard::Hashtag;
|
||||||
|
|
||||||
use crate::{EventSender, MostrMessage};
|
use crate::{EventSender, MostrMessage};
|
||||||
use crate::helpers::{format_timestamp_local, format_timestamp_relative, format_timestamp_relative_to, parse_tracking_stamp, some_non_empty};
|
use crate::helpers::{CHARACTER_THRESHOLD, format_timestamp_local, format_timestamp_relative, format_timestamp_relative_to, parse_tracking_stamp, some_non_empty};
|
||||||
use crate::kinds::*;
|
use crate::kinds::*;
|
||||||
use crate::task::{MARKER_DEPENDS, MARKER_PARENT, State, Task, TaskState};
|
use crate::task::{MARKER_DEPENDS, MARKER_PARENT, State, Task, TaskState};
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ impl Tasks {
|
||||||
"desc",
|
"desc",
|
||||||
].into_iter().map(|s| s.to_string()).collect(),
|
].into_iter().map(|s| s.to_string()).collect(),
|
||||||
sorting: [
|
sorting: [
|
||||||
"author",
|
|
||||||
"state",
|
"state",
|
||||||
|
"author",
|
||||||
"hashtags",
|
"hashtags",
|
||||||
"rtime",
|
"rtime",
|
||||||
"name",
|
"name",
|
||||||
|
@ -490,7 +490,7 @@ impl Tasks {
|
||||||
}
|
}
|
||||||
"progress" => prog_string.clone(),
|
"progress" => prog_string.clone(),
|
||||||
|
|
||||||
"author" => self.get_author(&task.event.pubkey),
|
"author" => format!("{:.6}", self.get_author(&task.event.pubkey)), // FIXME temporary until proper column alignment
|
||||||
"path" => self.get_task_path(Some(task.event.id)),
|
"path" => self.get_task_path(Some(task.event.id)),
|
||||||
"rpath" => self.relative_path(task.event.id),
|
"rpath" => self.relative_path(task.event.id),
|
||||||
// TODO format strings configurable
|
// TODO format strings configurable
|
||||||
|
@ -594,12 +594,11 @@ impl Tasks {
|
||||||
0 => {
|
0 => {
|
||||||
// No match, new task
|
// No match, new task
|
||||||
self.view.clear();
|
self.view.clear();
|
||||||
if arg.len() > 2 {
|
if arg.len() < CHARACTER_THRESHOLD {
|
||||||
Some(self.make_task_with(arg, self.position_tags_for(position), true))
|
warn!("New task name needs at least {CHARACTER_THRESHOLD} characters");
|
||||||
} else {
|
return None
|
||||||
warn!("Name of a task needs to have at least 3 characters");
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
Some(self.make_task_with(arg, self.position_tags_for(position), true))
|
||||||
}
|
}
|
||||||
1 => {
|
1 => {
|
||||||
// One match, activate
|
// One match, activate
|
||||||
|
|
Loading…
Reference in New Issue