diff --git a/src/loader.rs b/src/loader.rs index 6644c4b..b7adc08 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use gloo_file::callbacks::FileReader; use gloo_file::File; -use web_sys::{Event, HtmlInputElement, Url, MouseEvent}; +use web_sys::{Event, HtmlInputElement, MouseEvent, Url}; use yew::{html, html::TargetCast, Component, Context, Html}; use super::utils; @@ -45,6 +45,7 @@ impl Component for Loader { if self.files.len() == self.count { ctx.link().send_message(Msg::FilesLoaded); } + true } @@ -72,6 +73,7 @@ impl Component for Loader { }; self.readers.insert(file_name, task); } + true } @@ -81,7 +83,7 @@ impl Component for Loader { Err(err) => { utils::alert(&err.to_string()); ctx.link().send_message(Msg::Reset); - return true + return true; } }; @@ -92,7 +94,9 @@ impl Component for Loader { let url = Url::create_object_url_with_blob(&merged).unwrap(); anchor_element.set_attribute("href", &url).unwrap(); - anchor_element.set_attribute("download", "merged.gpx").unwrap(); + anchor_element + .set_attribute("download", "merged.gpx") + .unwrap(); self.is_loading = false; @@ -108,6 +112,7 @@ impl Component for Loader { self.count = 0; self.is_loading = false; self.field_value = ""; + true } } diff --git a/src/utils.rs b/src/utils.rs index 4201c17..23ded6f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,6 +1,6 @@ use std::error::Error; -use web_sys::Blob; use wasm_bindgen::prelude::*; +use web_sys::Blob; fn join_gpx_files(files: &Vec) -> Result> { let mut merged_gpx: gpx::Gpx = Default::default(); @@ -54,12 +54,12 @@ fn write_gpx_to_buffer(gpx: gpx::Gpx) -> Result> { pub fn merge(files: &Vec) -> Result> { let merged: gpx::Gpx = join_gpx_files(files)?; let out_vec = write_gpx_to_buffer(merged)?; - let result = Blob::new_with_u8_array_sequence(&out_vec).map_err(|e| e.as_string().unwrap() )?; + let result = Blob::new_with_u8_array_sequence(&out_vec).map_err(|e| e.as_string().unwrap())?; Ok(result) } #[wasm_bindgen] -extern { +extern "C" { pub fn alert(s: &str); }