Fix directory counters not updating
This commit is contained in:
@@ -128,6 +128,9 @@ onMount(get_reporters);
|
|||||||
<section>
|
<section>
|
||||||
<div class="toolbar" style="text-align: left;">
|
<div class="toolbar" style="text-align: left;">
|
||||||
<div class="toolbar_spacer"></div>
|
<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}}>
|
<button bind:this={edit_button} class:button_highlight={creating} on:click={() => {creating = !creating}}>
|
||||||
<i class="icon">create</i> Add abuse reporter
|
<i class="icon">create</i> Add abuse reporter
|
||||||
</button>
|
</button>
|
||||||
|
@@ -26,12 +26,11 @@ let total_files = 0
|
|||||||
let total_file_size = 0
|
let total_file_size = 0
|
||||||
|
|
||||||
const update_base = async () => {
|
const update_base = async () => {
|
||||||
if (!nav.initialized || connected_to === nav.base.path) {
|
if (!nav.initialized) {
|
||||||
return
|
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_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_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)
|
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") {
|
if (nav.base.type === "dir") {
|
||||||
console.debug("Not opening websocket for directory")
|
console.debug("Not opening websocket for directory")
|
||||||
return
|
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
|
// If the socket is already active we need to close it
|
||||||
close_socket()
|
close_socket()
|
||||||
|
Reference in New Issue
Block a user