diff --git a/noters/src/components.rs b/noters/src/components.rs index 0ae348e..a6419a7 100644 --- a/noters/src/components.rs +++ b/noters/src/components.rs @@ -27,6 +27,15 @@ fn truncate(s: String, max_chars: usize) -> String { } } +macro_rules! skip_fail { + ($result:expr) => { + match $result { + Ok(val) => val, + Err(_) => continue, + } + }; +} + #[component(DefaultView)] pub fn default_view(props: DefaultViewProps) -> Template { let mode = props.mode; @@ -43,7 +52,8 @@ pub fn default_view(props: DefaultViewProps) -> Template { let note = local_storage::get_item(&res); let trunced = truncate(note, 75); - let timestamp = format!("Created at {}", time_hr(res.parse::().unwrap())); + let timestamp = + format!("Created at {}", time_hr(skip_fail!(res.parse::()))); // Create new Strings to fix ownership problems let detail_res = (&res[..]).to_string(); let delete_res = (&res[..]).to_string(); diff --git a/noters/src/main.rs b/noters/src/main.rs index 44b1c60..6ba7cc5 100644 --- a/noters/src/main.rs +++ b/noters/src/main.rs @@ -29,17 +29,6 @@ fn main() { let mode = Signal::new(AppMode::Default); let selected = Signal::new(String::new()); - // Remove all keys that are not numbers (e.g. unix timestamps) - for key in local_storage::list_local_storage_keys().to_vec() { - if key.is_string() { - if let Some(res) = key.as_string() { - if let Err(_) = res.parse::() { - local_storage::remove_item(&res); - } - } - } - } - sycamore::render(|| { template! { h1(style="text-align: center") { "NoteRS" }