aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-05-13 13:41:26 +0530
committerkrolxon <krolyxon@tutanota.com>2024-05-13 13:41:26 +0530
commitbb5bcea3ff0f3205d087637ab485ef066309adeb (patch)
treef01679f5c49419b076b754ce8a535a767795d694 /src/app.rs
parent1e02da68ccbf3abc6465a72cc01b3487f2285048 (diff)
fix #4
Diffstat (limited to 'src/app.rs')
-rwxr-xr-xsrc/app.rs35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/app.rs b/src/app.rs
index 61f9e9e..bcfeeab 100755
--- a/src/app.rs
+++ b/src/app.rs
@@ -12,12 +12,12 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
/// Application
#[derive(Debug)]
pub struct App {
- pub running: bool, // Check if app is running
- pub conn: Connection, // Connection
- pub browser: FileBrowser, // Directory browser
- pub queue_list: ContentList<Song>, // Stores the current playing queue
- pub pl_list: ContentList<String>, // Stores list of playlists
- pub selected_tab: SelectedTab, // Used to switch between tabs
+ pub running: bool, // Check if app is running
+ pub conn: Connection, // Connection
+ pub browser: FileBrowser, // Directory browser
+ pub queue_list: ContentList<Song>, // Stores the current playing queue
+ pub pl_list: ContentList<String>, // Stores list of playlists
+ pub selected_tab: SelectedTab, // Used to switch between tabs
// Search
pub inputmode: InputMode, // Defines input mode, Normal or Search
@@ -194,15 +194,6 @@ impl App {
browser.selected = 0;
}
} else {
- // let list = conn
- // .songs_filenames
- // .iter()
- // .map(|f| f.as_str())
- // .collect::<Vec<&str>>();
- // let (filename, _) = rust_fuzzy_search::fuzzy_search_sorted(&path, &list)
- // .get(0)
- // .unwrap()
- // .clone();
let index = self
.queue_list
.list
@@ -212,12 +203,14 @@ impl App {
if index.is_some() {
self.conn.conn.switch(index.unwrap() as u32)?;
} else {
- for filename in self.conn.songs_filenames.clone().iter() {
- if filename.contains(path) {
- let song = self.conn.get_song_with_only_filename(filename);
- self.conn.push(&song)?;
- }
- }
+ let mut filename = format!("{}/{}", browser.path, path);
+
+ // Remove "./" from the beginning of filename
+ filename.remove(0);
+ filename.remove(0);
+
+ let song = self.conn.get_song_with_only_filename(&filename);
+ self.conn.push(&song)?;
// updating queue, to avoid multiple pushes of the same songs if we enter multiple times before the queue gets updated
self.update_queue();