This commit is contained in:
krolxon 2024-05-13 13:41:26 +05:30
parent 1e02da68cc
commit bb5bcea3ff
2 changed files with 16 additions and 26 deletions

View File

@ -194,15 +194,6 @@ impl App {
browser.selected = 0; browser.selected = 0;
} }
} else { } 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 let index = self
.queue_list .queue_list
.list .list
@ -212,12 +203,14 @@ impl App {
if index.is_some() { if index.is_some() {
self.conn.conn.switch(index.unwrap() as u32)?; self.conn.conn.switch(index.unwrap() as u32)?;
} else { } else {
for filename in self.conn.songs_filenames.clone().iter() { let mut filename = format!("{}/{}", browser.path, path);
if filename.contains(path) {
let song = self.conn.get_song_with_only_filename(filename); // 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)?; self.conn.push(&song)?;
}
}
// updating queue, to avoid multiple pushes of the same songs if we enter multiple times before the queue gets updated // updating queue, to avoid multiple pushes of the same songs if we enter multiple times before the queue gets updated
self.update_queue(); self.update_queue();

View File

@ -1,3 +1,4 @@
use ratatui::prelude::*;
use rmptui::app::App; use rmptui::app::App;
use rmptui::app::AppResult; use rmptui::app::AppResult;
use rmptui::event::event::Event; use rmptui::event::event::Event;
@ -6,10 +7,6 @@ use rmptui::event::handler;
use rmptui::tui; use rmptui::tui;
use std::env; use std::env;
use std::io; use std::io;
use ratatui::prelude::*;
pub type Result<T> = core::result::Result<T, Error>;
pub type Error = Box<dyn std::error::Error>;
fn main() -> AppResult<()> { fn main() -> AppResult<()> {
// Connection // Connection
@ -26,7 +23,7 @@ fn main() -> AppResult<()> {
tui.init()?; tui.init()?;
// initial directory read // initial directory read
app.browser.update_directory(&mut app.conn).unwrap(); app.browser.update_directory(&mut app.conn)?;
while app.running { while app.running {
tui.draw(&mut app)?; tui.draw(&mut app)?;