various: simplify code; work on security and performance

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I9a5114addcab5fbff430ab2b919b83466a6a6964
This commit is contained in:
raf 2026-02-02 17:32:11 +03:00
commit c4adc4e3e0
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
75 changed files with 12921 additions and 358 deletions

View file

@ -22,6 +22,7 @@ pub fn Import(
preview_files: Vec<DirectoryPreviewFile>,
preview_total_size: u64,
scan_progress: Option<ScanStatusResponse>,
#[props(default = false)] is_importing: bool,
) -> Element {
let mut import_mode = use_signal(|| 0usize);
let mut file_path = use_signal(String::new);
@ -44,6 +45,19 @@ pub fn Import(
let current_mode = *import_mode.read();
rsx! {
// Import status panel (shown when import is in progress)
if is_importing {
div { class: "import-status-panel",
div { class: "import-status-header",
div { class: "status-dot checking" }
span { "Import in progress..." }
}
div { class: "progress-bar",
div { class: "progress-fill indeterminate" }
}
}
}
// Tab bar
div { class: "import-tabs",
button {
@ -114,6 +128,7 @@ pub fn Import(
}
button {
class: "btn btn-primary",
disabled: is_importing,
onclick: {
let mut file_path = file_path;
let mut selected_tags = selected_tags;
@ -133,7 +148,7 @@ pub fn Import(
}
}
},
"Import"
if is_importing { "Importing..." } else { "Import" }
}
}
}
@ -494,7 +509,7 @@ pub fn Import(
rsx! {
button {
class: "btn btn-primary",
disabled: !has_selected,
disabled: !has_selected || is_importing,
onclick: {
let mut selected_file_paths = selected_file_paths;
let mut selected_tags = selected_tags;
@ -514,7 +529,9 @@ pub fn Import(
}
}
},
if has_selected {
if is_importing {
"Importing..."
} else if has_selected {
"Import Selected ({sel_count})"
} else {
"Import Selected"
@ -526,6 +543,7 @@ pub fn Import(
// Import entire directory
button {
class: "btn btn-secondary",
disabled: is_importing,
onclick: {
let mut dir_path = dir_path;
let mut selected_tags = selected_tags;
@ -547,7 +565,7 @@ pub fn Import(
}
}
},
"Import Entire Directory"
if is_importing { "Importing..." } else { "Import Entire Directory" }
}
}
}
@ -569,8 +587,9 @@ pub fn Import(
div { class: "mb-16", style: "text-align: center;",
button {
class: "btn btn-primary",
disabled: is_importing,
onclick: move |_| on_scan.call(()),
"Scan All Roots"
if is_importing { "Scanning..." } else { "Scan All Roots" }
}
}

View file

@ -41,14 +41,20 @@ impl Default for PlayQueue {
}
impl PlayQueue {
/// Check if the queue is empty.
#[allow(dead_code)]
pub fn is_empty(&self) -> bool {
self.items.is_empty()
}
/// Get the current item in the queue.
#[allow(dead_code)]
pub fn current(&self) -> Option<&QueueItem> {
self.items.get(self.current_index)
}
/// Advance to the next item based on repeat mode.
#[allow(dead_code)]
pub fn next(&mut self) -> Option<&QueueItem> {
if self.items.is_empty() {
return None;
@ -70,6 +76,8 @@ impl PlayQueue {
}
}
/// Go to the previous item based on repeat mode.
#[allow(dead_code)]
pub fn previous(&mut self) -> Option<&QueueItem> {
if self.items.is_empty() {
return None;
@ -82,10 +90,14 @@ impl PlayQueue {
self.items.get(self.current_index)
}
/// Add an item to the queue.
#[allow(dead_code)]
pub fn add(&mut self, item: QueueItem) {
self.items.push(item);
}
/// Remove an item from the queue by index.
#[allow(dead_code)]
pub fn remove(&mut self, index: usize) {
if index < self.items.len() {
self.items.remove(index);
@ -95,11 +107,15 @@ impl PlayQueue {
}
}
/// Clear all items from the queue.
#[allow(dead_code)]
pub fn clear(&mut self) {
self.items.clear();
self.current_index = 0;
}
/// Toggle between repeat modes: Off -> All -> One -> Off.
#[allow(dead_code)]
pub fn toggle_repeat(&mut self) {
self.repeat = match self.repeat {
RepeatMode::Off => RepeatMode::All,
@ -108,6 +124,8 @@ impl PlayQueue {
};
}
/// Toggle shuffle mode on/off.
#[allow(dead_code)]
pub fn toggle_shuffle(&mut self) {
self.shuffle = !self.shuffle;
}