diff options
author | Joan Lledó <jlledom@member.fsf.org> | 2023-09-23 14:04:18 +0200 |
---|---|---|
committer | Joan Lledó <jlledom@member.fsf.org> | 2023-09-30 13:14:52 +0200 |
commit | c6d5440c44ac7b94a9d7db38c36e638097872852 (patch) | |
tree | 957fb97fcedd33a251e625b85e3feb074faf27e8 /src/ui/window.rs | |
parent | 39761d3597c4ce6db1709501e3601b018aaeb233 (diff) | |
download | Furtherance-c6d5440c44ac7b94a9d7db38c36e638097872852.tar.zst |
Error management for `update_list_model()`
Diffstat (limited to 'src/ui/window.rs')
-rw-r--r-- | src/ui/window.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ui/window.rs b/src/ui/window.rs index 0f54828..ccf2364 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -218,7 +218,7 @@ impl FurtheranceWindow { if task_input.text().len() >= FurtheranceWindow::MIN_PREFIX_LENGTH.try_into().unwrap() { let task_autocomplete = task_input.completion().unwrap(); - let model = Self::update_list_model(task_name.to_string()); + let model = Self::update_list_model(task_name.to_string()).unwrap(); task_autocomplete.set_model(Some(&model)); } })); @@ -544,16 +544,16 @@ impl FurtheranceWindow { imp.task_input.set_activates_default(true); } - fn update_list_model(task_name: String) -> gtk::ListStore { + fn update_list_model(task_name: String) -> Result<gtk::ListStore, anyhow::Error> { let col_types: [glib::Type; 1] = [glib::Type::STRING]; - let mut task_list = database::get_list_by_name(task_name).unwrap(); + let mut task_list = database::get_list_by_name(task_name)?; task_list.dedup_by(|a, b| a.task_name == b.task_name && a.tags == b.tags); let store = gtk::ListStore::new(&col_types); for task in task_list { store.set(&store.append(), &[(0, &task.to_string())]); } - store + Ok(store) } fn get_idle_time(&self) -> Result<u64, Box<dyn std::error::Error>> { |