Update to svelte 5
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script>
|
||||
import { preventDefault } from 'svelte/legacy';
|
||||
import UploadProgressBar from "home_page/UploadProgressBar.svelte"
|
||||
import { tick } from "svelte"
|
||||
import UploadStats from "home_page/UploadStats.svelte";
|
||||
@@ -9,7 +10,7 @@ export const pick_files = () => {
|
||||
|
||||
// === UPLOAD LOGIC ===
|
||||
|
||||
let file_input_field
|
||||
let file_input_field = $state()
|
||||
const file_input_change = (event) => {
|
||||
// Start uploading the files async
|
||||
upload_files(event.target.files)
|
||||
@@ -26,9 +27,9 @@ const paste = (e) => {
|
||||
}
|
||||
|
||||
let active_uploads = 0
|
||||
let upload_queue = []
|
||||
let state = "idle" // idle, uploading, finished
|
||||
let upload_stats
|
||||
let upload_queue = $state([])
|
||||
let status = $state("idle") // idle, uploading, finished
|
||||
let upload_stats = $state()
|
||||
|
||||
export const upload_files = async (files) => {
|
||||
if (files.length === 0) {
|
||||
@@ -77,10 +78,10 @@ const start_upload = () => {
|
||||
}
|
||||
|
||||
if (active_uploads === 0 && finished_count != 0) {
|
||||
state = "finished"
|
||||
status = "finished"
|
||||
upload_stats.finish()
|
||||
} else {
|
||||
state = "uploading"
|
||||
status = "uploading"
|
||||
upload_stats.start()
|
||||
}
|
||||
}
|
||||
@@ -91,7 +92,7 @@ const finish_upload = (file) => {
|
||||
}
|
||||
|
||||
const leave_confirmation = e => {
|
||||
if (state === "uploading") {
|
||||
if (status === "uploading") {
|
||||
e.preventDefault()
|
||||
e.returnValue = "If you close the page your files will stop uploading. Do you want to continue?"
|
||||
return e.returnValue
|
||||
@@ -103,7 +104,7 @@ const leave_confirmation = e => {
|
||||
// === SHARING BUTTONS ===
|
||||
|
||||
let share_link = ""
|
||||
let input_album_name = ""
|
||||
let input_album_name = $state("")
|
||||
|
||||
let btn_create_list
|
||||
|
||||
@@ -172,19 +173,19 @@ const keydown = (e) => {
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window on:paste={paste} on:keydown={keydown} on:beforeunload={leave_confirmation} />
|
||||
<svelte:window onpaste={paste} onkeydown={keydown} onbeforeunload={leave_confirmation} />
|
||||
|
||||
<input bind:this={file_input_field} on:change={file_input_change} type="file" name="file" multiple="multiple" class="hide"/>
|
||||
<input bind:this={file_input_field} onchange={file_input_change} type="file" name="file" multiple="multiple" class="hide"/>
|
||||
|
||||
<UploadStats bind:this={upload_stats} upload_queue={upload_queue}/>
|
||||
|
||||
{#if upload_queue.length > 1}
|
||||
<div class="album_widget">
|
||||
Create an album<br/>
|
||||
<form class="album_name_form" on:submit|preventDefault={create_album}>
|
||||
<form class="album_name_form" onsubmit={preventDefault(create_album)}>
|
||||
<div>Name:</div>
|
||||
<input bind:value={input_album_name} type="text" placeholder="My album"/>
|
||||
<button type="submit" disabled={state !== "finished"}>
|
||||
<button type="submit" disabled={status !== "finished"}>
|
||||
<i class="icon">create_new_folder</i> Create
|
||||
</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user