summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-07-24 18:37:52 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-07-24 18:37:52 +0200
commit4f72c47b781fed4b7b33a06c6a6d712bdcd32684 (patch)
tree0555f927fa7e1c777072f691b1430454846b898b
parentc8cf1c705b86f22c1d2ae8fe835ea4d4add27667 (diff)
Do not database_path.unwrap()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-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");