fix(app): make s3 uploads persistent across tabs change

This commit is contained in:
Ruben Fiszel
2024-10-16 19:42:52 +02:00
parent bfc1f53cea
commit 8a926acdb6
3 changed files with 9 additions and 6 deletions
@@ -44,8 +44,9 @@
}
}
let value: { path: string; filename: string }[] | undefined = undefined
const outputs = initOutput($worldStore, id, {
result: [] as { path: string; filename: string }[] | undefined,
result: value ?? ([] as { path: string; filename: string }[] | undefined),
loading: false,
jobId: undefined
})
@@ -124,15 +125,18 @@
customResourceType="s3"
customClass={css?.container?.class}
customStyle={css?.container?.style}
{fileUploads}
{workspace}
on:addition={(evt) => {
const curr = outputs.result.peak()
outputs.result.set(curr.concat(evt.detail))
value = curr.concat(evt.detail)
outputs.result.set(value)
onFileChange?.forEach((id) => $runnableComponents?.[id]?.cb?.forEach((cb) => cb?.()))
}}
on:deletion={(evt) => {
const curr = outputs.result.peak()
outputs.result.set(curr.filter((file) => file.path !== evt.detail?.path))
value = curr.filter((file) => file.path !== evt.detail?.path)
outputs.result.set(value)
}}
{forceDisplayUploads}
/>
@@ -43,7 +43,7 @@
let value: string | undefined = resolvedConfig.defaultValue
let outputs = initOutput($worldStore, id, {
result: ''
result: value ?? ''
})
onDestroy(() => {
@@ -24,6 +24,7 @@
export let forceDisplayUploads: boolean = false
export let defaultValue: string | undefined = undefined
export let workspace: string | undefined = undefined
export let fileUploads: Writable<FileUploadData[]> = writable([])
const dispatch = createEventDispatcher()
@@ -37,8 +38,6 @@
file?: File
}
let fileUploads: Writable<FileUploadData[]> = writable([])
async function handleChange(files: File[] | undefined) {
for (const file of files ?? []) {
uploadFileToS3(file, file.name)