Skip to content

Commit

Permalink
fix(app): make s3 uploads persistent across tabs change
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfiszel committed Oct 16, 2024
1 parent c06c42a commit c3b536b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down Expand Up @@ -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}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
let value: string | undefined = resolvedConfig.defaultValue
let outputs = initOutput($worldStore, id, {
result: ''
result: value ?? ''
})
onDestroy(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit c3b536b

Please sign in to comment.