Simply skip failing entries instead of removing them
This commit is contained in:
parent
c737b4f628
commit
c73d68ed64
|
@ -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<G>)]
|
||||
pub fn default_view(props: DefaultViewProps) -> Template<G> {
|
||||
let mode = props.mode;
|
||||
|
@ -43,7 +52,8 @@ pub fn default_view(props: DefaultViewProps) -> Template<G> {
|
|||
let note = local_storage::get_item(&res);
|
||||
let trunced = truncate(note, 75);
|
||||
|
||||
let timestamp = format!("Created at {}", time_hr(res.parse::<u64>().unwrap()));
|
||||
let timestamp =
|
||||
format!("Created at {}", time_hr(skip_fail!(res.parse::<u64>())));
|
||||
// Create new Strings to fix ownership problems
|
||||
let detail_res = (&res[..]).to_string();
|
||||
let delete_res = (&res[..]).to_string();
|
||||
|
|
|
@ -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::<u64>() {
|
||||
local_storage::remove_item(&res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sycamore::render(|| {
|
||||
template! {
|
||||
h1(style="text-align: center") { "NoteRS" }
|
||||
|
|
Loading…
Reference in a new issue