aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-04-28 16:42:50 +0530
committerkrolxon <krolyxon@tutanota.com>2024-04-28 16:42:50 +0530
commit6e631a0520053c7d3435a193f61e89e695c91f08 (patch)
tree17d3d080c2e3afcfeb30e8ed3e4fd01e1ae22f6e /src/app.rs
parent5eafc1898bf41ce2e6d3a634724f9443546af614 (diff)
add unadded songs to queue on <space>
Diffstat (limited to 'src/app.rs')
-rwxr-xr-xsrc/app.rs35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/app.rs b/src/app.rs
index 5c74245..4593867 100755
--- a/src/app.rs
+++ b/src/app.rs
@@ -114,34 +114,47 @@ impl App {
Ok(())
}
- pub fn remove_from_current_playlist(&mut self) {
- let mut file = String::new();
+ pub fn handle_remove_or_from_current_playlist(&mut self) -> AppResult<()> {
match self.selected_tab {
SelectedTab::DirectoryBrowser => {
- let (_, f) = self.browser.filetree.get(self.browser.selected).unwrap();
- file.push_str(f);
+ let (_, file) = self.browser.filetree.get(self.browser.selected).unwrap();
self.browser.selected += 1;
+ let mut status = false;
+ for (i, song) in self.queue_list.list.clone().iter().enumerate() {
+ if song.contains(file) {
+ self.conn.conn.delete(i as u32).unwrap();
+ status = true;
+ }
+ }
+
+ if !status {
+ let song = self
+ .conn
+ .get_song_with_only_filename(&self.conn.get_full_path(&file).unwrap());
+ self.conn.conn.push(&song)?;
+ }
}
SelectedTab::Queue => {
- file = self
+ let 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();
+ }
+ }
}
_ => {}
}
- 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();
+ Ok(())
}
pub fn cycle_tabls(&mut self) {