Here is my fn main
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![select_directory,scan_directory, check_audio_channels, load_audio_file ])
.plugin(tauri_plugin_store::Builder::default().build())
.setup(|app| {
// Get the path to the app's configuration directory
let config_dir = app.path_resolver().app_config_dir().ok_or_else(|| {
eprintln!("Failed to resolve app config directory");
Box::<dyn std::error::Error>::from("Failed to resolve app config directory")
})?;
let settings_path = config_dir.join("settings.json");
// Create the store
let mut store = StoreBuilder::new(app.handle(), settings_path.clone()).build();
// Insert the initial value for baseFolder
match store.insert("baseFolder".to_string(), json!("testing")) {
Ok(_) => {
match store.save() {
Ok(_) => Ok(()),
Err(e) => {
eprintln!("Failed to save store: {}", e);
Err(Box::new(e))
}
}
},
Err(e) => {
eprintln!("Failed to insert initial value: {}", e);
Err(Box::new(e))
}
}?;
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Now my question is does doing this on the frontend create a new instance of the store thats different from the one we created on the backend?
import { appConfigDir } from '@tauri-apps/api/path';
import { Store } from 'tauri-plugin-store-api';
const appConfigDirPath = await appConfigDir();
export const store = new Store(appConfigDirPath + 'settings.json');