Skip to content

Commit 42555f9

Browse files
committed
feat(settings): read notes
now has 3 new buttons to delete cache, assets and configs
1 parent a6d6522 commit 42555f9

File tree

3 files changed

+106
-6
lines changed

3 files changed

+106
-6
lines changed

src-tauri/src/lib.rs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,56 @@ async fn run_simba(path: PathBuf, args: Vec<String>) {
333333
let _ = cmd.spawn().map_err(|err| err.to_string());
334334
}
335335

336+
#[tauri::command]
337+
fn delete_cache(paths: State<'_, Mutex<ExecutablePaths>>) -> tauri::Result<()> {
338+
let path = {
339+
let paths = paths.lock().unwrap();
340+
paths.simba.clone()
341+
};
342+
let cache_path = path.join("Data/Cache");
343+
344+
if cache_path.exists() {
345+
remove_dir_all(&cache_path).expect("Failed to delete cache path.");
346+
println!("Deleted folder: {:?}", cache_path);
347+
}
348+
349+
Ok(())
350+
}
351+
352+
#[tauri::command]
353+
fn delete_assets(paths: State<'_, Mutex<ExecutablePaths>>) -> tauri::Result<()> {
354+
let path = {
355+
let paths = paths.lock().unwrap();
356+
paths.simba.clone()
357+
};
358+
359+
let assets_path = path.join("Data/Assets");
360+
361+
if assets_path.exists() {
362+
remove_dir_all(&assets_path).expect("Failed to delete assets path.");
363+
println!("Deleted folder: {:?}", assets_path);
364+
}
365+
366+
Ok(())
367+
}
368+
369+
#[tauri::command]
370+
fn delete_configs(paths: State<'_, Mutex<ExecutablePaths>>) -> tauri::Result<()> {
371+
let path = {
372+
let paths = paths.lock().unwrap();
373+
paths.simba.clone()
374+
};
375+
376+
let assets_path = path.join("Configs");
377+
378+
if assets_path.exists() {
379+
remove_dir_all(&assets_path).expect("Failed to delete configs path.");
380+
println!("Deleted folder: {:?}", assets_path);
381+
}
382+
383+
Ok(())
384+
}
385+
336386
fn send_html(content: &str) -> String {
337387
let html = format!(
338388
"<!DOCTYPE html>\n\
@@ -667,7 +717,10 @@ pub fn run() {
667717
run_executable,
668718
start_server,
669719
sign_up,
670-
save_blob
720+
save_blob,
721+
delete_cache,
722+
delete_assets,
723+
delete_configs
671724
])
672725
.run(tauri::generate_context!())
673726
.expect("error while running tauri application");

src/routes/scripts/+layout.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
let { data, children } = $props()
77
const scripts = $derived(data.scripts!)
8-
98
let search = $state("")
109
1110
$inspect(data.script)

src/routes/settings/+page.svelte

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@
3030
await invoke("set_executable_path", { exe, path })
3131
await invalidate("executable:paths")
3232
}
33+
34+
let deletingAssets = $state(false)
35+
async function clearAssets() {
36+
deletingAssets = true
37+
await invoke("delete_assets")
38+
deletingAssets = false
39+
}
40+
41+
let deletingCache = $state(false)
42+
async function clearCache() {
43+
deletingCache = true
44+
await invoke("delete_cache")
45+
deletingCache = false
46+
}
47+
48+
let deletingConfigs = $state(false)
49+
async function clearConfigs() {
50+
deletingConfigs = true
51+
await invoke("delete_configs")
52+
deletingConfigs = false
53+
}
3354
</script>
3455

3556
<main class="flex flex-col">
@@ -42,8 +63,8 @@
4263
<ArrowBigLeft />
4364
</a>
4465

45-
<div class="flex">
46-
<div class="m-12 space-y-8 rounded-md preset-outlined-surface-300-700 p-12">
66+
<div class="flex gap-2">
67+
<div class="m-4 space-y-8 rounded-md preset-outlined-surface-300-700 p-12">
4768
<header>
4869
<h1 class="text-xl font-bold">OSRS Clients:</h1>
4970
</header>
@@ -67,7 +88,7 @@
6788
</label>
6889
</div>
6990

70-
<div class="m-12 space-y-8 rounded-md preset-outlined-surface-300-700 p-12">
91+
<div class="m-4 space-y-8 rounded-md preset-outlined-surface-300-700 p-12">
7192
<header>
7293
<h1 class="text-xl font-bold">Development Environment:</h1>
7394
</header>
@@ -90,7 +111,34 @@
90111
</div>
91112
</div>
92113

93-
<span class="w-full text-center font-bold text-surface-800-200">
114+
<div class="mx-auto my-4 flex gap-2">
115+
<button
116+
class="btn bg-secondary-500"
117+
class:disabled={deletingCache}
118+
disabled={deletingCache}
119+
onclick={async () => await clearCache()}
120+
>
121+
Clear Cache
122+
</button>
123+
<button
124+
class="btn bg-secondary-500"
125+
class:disabled={deletingAssets}
126+
disabled={deletingAssets}
127+
onclick={async () => await clearAssets()}
128+
>
129+
Clear Assets
130+
</button>
131+
<button
132+
class="btn bg-secondary-500"
133+
class:disabled={deletingConfigs}
134+
disabled={deletingConfigs}
135+
onclick={async () => await clearConfigs()}
136+
>
137+
Clear Configs
138+
</button>
139+
</div>
140+
141+
<span class="my-4 w-full text-center font-bold text-surface-800-200">
94142
wasp-launcher v{#await getVersion()} Loading...{:then version}{version}{/await}</span
95143
>
96144
</main>

0 commit comments

Comments
 (0)