h-gtk: Show error notifications when OPML import fails.

This commit is contained in:
Jordan Petridis 2018-05-16 17:39:29 +03:00
parent 118dac5a1a
commit ccd3e3ab2c
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 10 additions and 7 deletions

View File

@ -19,7 +19,6 @@ use std::rc::Rc;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc;
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub enum Action {
RefreshAllViews,
@ -205,11 +204,8 @@ impl App {
}
Ok(Action::ErrorNotification(err)) => {
error!("An error notification was triggered: {}", err);
// FIXME: this is not good user-facing messages.
// should match on the error type and return a proper description of the Error.
let text = &err;
let callback = || glib::Continue(false);
let notif = InAppNotification::new(text, callback, || {}, UndoState::Hidden);
let notif = InAppNotification::new(&err, callback, || {}, UndoState::Hidden);
notif.show(&overlay);
}
Err(_) => (),

View File

@ -269,10 +269,17 @@ fn on_import_clicked(window: &gtk::Window, sender: &Sender<Action>) {
// Refresh the succesfully parsed feeds to index them
utils::refresh(Some(sources), sender)
} else {
// TODO: Show an in-app notification if file can not be parsed
error!("Failed to parse the Import file")
let text = String::from("Failed to parse the Imported file");
sender.send(Action::ErrorNotification(text))
.map_err(|err| error!("Action Sender: {}", err))
.ok();
}
}))
} else {
let text = String::from("Selected File could not be accessed.");
sender.send(Action::ErrorNotification(text))
.map_err(|err| error!("Action Sender: {}", err))
.ok();
}
}