Skip to content

Commit

Permalink
Trigger scan on refresh clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovenoboyo committed Dec 22, 2024
1 parent 867de13 commit b4e4691
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src-tauri/preferences/src/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ impl PreferenceConfig {
config_file.write_all(&serde_json::to_vec(&writable)?)?;
config_file.flush()?;

let sender = self.sender.clone();
let parsed = serde_json::to_value(value).unwrap();

let sender = self.sender.clone();
thread::spawn(move || {
sender.send((key, parsed)).unwrap();
});
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl ScanTask {
}

#[tracing::instrument(level = "trace", skip(scanner, database, preferences, paths, force))]
#[tauri_invoke_proc::parse_tauri_command]
#[tauri::command(async)]
pub fn start_scan(
scanner: State<ScannerHolder>,
Expand Down
11 changes: 8 additions & 3 deletions src/components/prefs/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ pub fn PathsPref(
}
});

let start_scan = move |_| {
tracing::info!("Starting scan");
spawn_local(async move {
let _ = crate::utils::invoke::start_scan(None, true).await;
})
};

let key_clone = key.clone();
create_effect(move |_| {
let value = paths.get();
Expand All @@ -78,9 +85,7 @@ pub fn PathsPref(
</div>
</div>
<div class="col-auto new-directories ml-auto justify-content-center">
<div on:click=move |_| {
save_selective(key.clone(), paths.get())
}>{"Refresh"}</div>
<div on:click=start_scan>{"Refresh"}</div>
</div>
<div class="col-auto new-directories ml-4">
<div
Expand Down
1 change: 0 additions & 1 deletion src/pages/genres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pub fn AllGenres() -> impl IntoView {
redirect_root="/main/genre"
card_item=move |(_, item)| {
let genre_name = item.genre_name.clone().unwrap_or_default();
let genre_id = item.genre_id.clone().unwrap_or_default();
SimplifiedCardItem {
title: genre_name,
cover: None,
Expand Down
1 change: 0 additions & 1 deletion src/utils/db_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use futures::lock::Mutex;
use indexed_db_futures::IdbDatabase;
use indexed_db_futures::IdbQuerySource;
use leptos::{spawn_local, SignalSet, SignalUpdate};
use serde::Serialize;
use serde_wasm_bindgen::from_value;
use types::entities::QueryableAlbum;
use types::entities::QueryableArtist;
Expand Down

0 comments on commit b4e4691

Please sign in to comment.