summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main_view.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/main_view.rs b/src/main_view.rs
index 748c1ea..c406246 100644
--- a/src/main_view.rs
+++ b/src/main_view.rs
@@ -14,6 +14,7 @@ use cursive::views::Dialog;
use cursive::views::EditView;
use cursive::views::NamedView;
use cursive::views::ResizedView;
+use cursive::views::TextView;
use crate::configuration::Configuration;
use crate::maillist_view::MaillistView;
@@ -122,22 +123,30 @@ impl MainView {
main_view.config().notmuch_database_path().clone()
});
- let database_path = database_path.unwrap(); // TODO: Fixme
+ if let Some(database_path) = database_path {
+ let tab_name = format!("{}-view", query);
+ let tab = MaillistView::create_for(&database_path, query, query.to_string())
+ .unwrap() // TODO: FIXME
+ .with_name(tab_name);
- let tab_name = format!("{}-view", query);
- let tab = MaillistView::create_for(&database_path, query, query.to_string())
- .unwrap() // TODO: FIXME
- .with_name(tab_name);
+ let tab = ResizedView::new(cursive::view::SizeConstraint::Full,
+ cursive::view::SizeConstraint::Full,
+ tab);
- let tab = ResizedView::new(cursive::view::SizeConstraint::Full,
- cursive::view::SizeConstraint::Full,
- tab);
+ siv.call_on_name(MAIN_VIEW_NAME, move |main_view: &mut MainView| {
+ main_view.add_tab(query.to_string(), tab);
+ });
- siv.call_on_name(MAIN_VIEW_NAME, move |main_view: &mut MainView| {
- main_view.add_tab(query.to_string(), tab);
- });
+ siv.pop_layer();
+ } else {
+ siv.pop_layer();
+ siv.add_layer({
+ Dialog::around({
+ TextView::new("Failed to get database connection set up")
+ })
+ });
+ }
- siv.pop_layer();
})
.with_name("query");