From ccd3e3ab2cac904d9754a19c97a70fe61f49f7c3 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 16 May 2018 17:39:29 +0300 Subject: [PATCH] h-gtk: Show error notifications when OPML import fails. --- hammond-gtk/src/app.rs | 6 +----- hammond-gtk/src/headerbar.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index 02cfa75..4668aa3 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -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(_) => (), diff --git a/hammond-gtk/src/headerbar.rs b/hammond-gtk/src/headerbar.rs index 6c103e9..90c479c 100644 --- a/hammond-gtk/src/headerbar.rs +++ b/hammond-gtk/src/headerbar.rs @@ -269,10 +269,17 @@ fn on_import_clicked(window: >k::Window, sender: &Sender) { // 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(); } }