Skip to content

Commit

Permalink
fix: reload channels on tag delete
Browse files Browse the repository at this point in the history
  • Loading branch information
sarowish committed Dec 12, 2022
1 parent 0637d70 commit 4a63aed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- No longer crashes if no tag is selected when trying to modify channels of a tag.
- Reload channels when a tag is deleted.

## [0.3.1] - 2022-10-16
### Fixed
Expand Down
39 changes: 23 additions & 16 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,24 @@ impl App {
}
}

fn reload_channels(&mut self) {
let id_of_current_channel = self
.get_current_channel()
.map(|channel| channel.channel_id.clone());

self.load_channels();

if let Some(id) = id_of_current_channel {
if let Some(index) = self.channels.find_by_id(&id) {
self.channels.select_with_index(index);
} else {
self.channels.check_bounds();
};
}

self.on_change_channel();
}

pub fn set_mode_subs(&mut self) {
if !matches!(self.mode, Mode::Subscriptions) {
self.mode = Mode::Subscriptions;
Expand Down Expand Up @@ -1063,21 +1081,7 @@ impl App {
)
.unwrap();

let id_of_current_channel = self
.get_current_channel()
.map(|channel| channel.channel_id.clone());

self.load_channels();

if let Some(id) = id_of_current_channel {
if let Some(index) = self.channels.find_by_id(&id) {
self.channels.select_with_index(index);
} else {
self.channels.check_bounds();
};
}

self.on_change_channel();
self.reload_channels();

self.input_mode = InputMode::Tag;
}
Expand Down Expand Up @@ -1113,7 +1117,10 @@ impl App {
return;
}

self.tags.items.remove(idx);
if self.tags.items.remove(idx).selected {
self.reload_channels();
}

self.tags.check_bounds();
}
}
Expand Down

0 comments on commit 4a63aed

Please sign in to comment.