Fix directory counters not updating

This commit is contained in:
2024-09-25 16:30:55 +02:00
parent 828ef1c81a
commit 94760efc37
2 changed files with 8 additions and 3 deletions

View File

@@ -128,6 +128,9 @@ onMount(get_reporters);
<section>
<div class="toolbar" style="text-align: left;">
<div class="toolbar_spacer"></div>
<button on:click={() => get_reporters()}>
<i class="icon">refresh</i>
</button>
<button bind:this={edit_button} class:button_highlight={creating} on:click={() => {creating = !creating}}>
<i class="icon">create</i> Add abuse reporter
</button>

View File

@@ -26,12 +26,11 @@ let total_files = 0
let total_file_size = 0
const update_base = async () => {
if (!nav.initialized || connected_to === nav.base.path) {
if (!nav.initialized) {
return
}
connected_to = nav.base.path
// Tallys
// Update counters with new info
total_directories = nav.children.reduce((acc, cur) => cur.type === "dir" ? acc + 1 : acc, 0)
total_files = nav.children.reduce((acc, cur) => cur.type === "file" ? acc + 1 : acc, 0)
total_file_size = nav.children.reduce((acc, cur) => acc + cur.file_size, 0)
@@ -39,7 +38,10 @@ const update_base = async () => {
if (nav.base.type === "dir") {
console.debug("Not opening websocket for directory")
return
} else if (connected_to === nav.base.path) {
return // If we're already connected to the same path, don't reconnect
}
connected_to = nav.base.path
// If the socket is already active we need to close it
close_socket()