Skip to content

Commit

Permalink
fix: check if a tag is selected before trying to modify its channels
Browse files Browse the repository at this point in the history
  • Loading branch information
sarowish committed Nov 3, 2022
1 parent 3df9197 commit 3b62766
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 11 additions & 10 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3b62766

Please sign in to comment.