added keybind to remove highlighted song from queue

This commit is contained in:
krolxon 2024-04-27 13:22:55 +05:30
parent 255687be7c
commit ad2e99ce76
2 changed files with 29 additions and 0 deletions

View File

@ -113,6 +113,30 @@ impl App {
Ok(())
}
pub fn remove_from_current_playlist(&mut self) {
let mut file = String::new();
match self.selected_tab {
SelectedTab::DirectoryBrowser => {
let (_, f) = self.browser.filetree.get(self.browser.selected).unwrap();
file.push_str(f);
}
SelectedTab::Queue => {
file = self.queue_list.list.get(self.queue_list.index).unwrap().to_string();
}
_ => {}
}
for (i, song) in self.queue_list.list.clone().iter().enumerate() {
if song.contains(&file) {
self.conn.conn.delete(i as u32).unwrap();
}
}
self.update_queue();
}
pub fn cycle_tabls(&mut self) {
self.selected_tab = match self.selected_tab {
SelectedTab::DirectoryBrowser => SelectedTab::Queue,

View File

@ -284,6 +284,11 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
app.inputmode = InputMode::toggle_editing_states(&app.inputmode);
}
// Remove from Current Playlsit
KeyCode::Backspace => {
app.remove_from_current_playlist();
}
_ => {}
}
}