Avoid export of an empty file

This commit is contained in:
Emilia Allison 2023-06-05 14:56:01 -04:00
parent 3bd3873043
commit b14278dda8
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
1 changed files with 4 additions and 0 deletions

View File

@ -72,6 +72,10 @@ pub fn MainWindow() -> Html {
let save_button_callback = { let save_button_callback = {
let main_state = main_state.clone(); let main_state = main_state.clone();
Callback::from(move |_| { Callback::from(move |_| {
if main_state.transfers.len() == 0 {
web_sys::window().unwrap().alert_with_message("No transfers to export.").unwrap();
return ()
}
if let Ok(csv) = state_to_csv(&main_state) { if let Ok(csv) = state_to_csv(&main_state) {
let csv: &str = &csv; let csv: &str = &csv;
let blob = Blob::new_with_str_sequence( let blob = Blob::new_with_str_sequence(