diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bbaed8..5a9452d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- No longer crashes if no tag is selected when trying to modify channels of a tag. ## [0.3.1] - 2022-10-16 ### Fixed diff --git a/src/app.rs b/src/app.rs index 52b2861..bf5f667 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1001,21 +1001,22 @@ impl App { } pub fn enter_channel_selection(&mut self) { - self.input_mode = InputMode::ChannelSelection; + if let Some(selected_tag) = &self.tags.get_selected() { + self.input_mode = InputMode::ChannelSelection; - let selected_tag = &self.tags.get_selected().unwrap(); + let mut all_channels = + SelectionList::new(database::get_channels(&self.conn, &[]).unwrap()); - let mut all_channels = SelectionList::new(database::get_channels(&self.conn, &[]).unwrap()); + let selected_channels = database::get_channels(&self.conn, &[selected_tag]).unwrap(); - let selected_channels = database::get_channels(&self.conn, &[selected_tag]).unwrap(); - - for channel in selected_channels { - if let Some(c) = all_channels.get_mut_by_id(&channel.channel_id) { - c.selected = true; + for channel in selected_channels { + if let Some(c) = all_channels.get_mut_by_id(&channel.channel_id) { + c.selected = true; + } } - } - self.channel_selection = all_channels; + self.channel_selection = all_channels; + } } pub fn update_tag(&mut self) {