mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-17 16:50:22 +00:00
Merge 47f69d8a8a into 0b1f79c90d
This commit is contained in:
commit
6bd4e12350
2 changed files with 19 additions and 8 deletions
5
.changeset/nice-jeans-sniff.md
Normal file
5
.changeset/nice-jeans-sniff.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@uppy/svelte": patch
|
||||
---
|
||||
|
||||
Fix only capturing the initial value of `uppy` in `UppyContextProvider`
|
||||
|
|
@ -14,12 +14,18 @@ export type { UppyContext } from "@uppy/components";
|
|||
|
||||
let { uppy, children } = $props()
|
||||
|
||||
// Create a single reactive context object
|
||||
const contextValue: UppyContext = $state({
|
||||
uppy,
|
||||
status: 'init' as UploadStatus,
|
||||
progress: 0,
|
||||
})
|
||||
// Create reactive state for properties of the context
|
||||
let status = $state('init' as UploadStatus)
|
||||
let progress = $state(0)
|
||||
|
||||
// Create a single context object, with some reactive properties
|
||||
const contextValue: UppyContext = {
|
||||
get uppy() { return uppy },
|
||||
get status() { return status },
|
||||
set status(value) { status = value },
|
||||
get progress() { return progress },
|
||||
set progress(value) { progress = value },
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (!uppy) {
|
||||
|
|
@ -29,10 +35,10 @@ export type { UppyContext } from "@uppy/components";
|
|||
const uppyEventAdapter = createUppyEventAdapter({
|
||||
uppy,
|
||||
onStatusChange: (newStatus: UploadStatus) => {
|
||||
contextValue.status = newStatus
|
||||
status = newStatus
|
||||
},
|
||||
onProgressChange: (newProgress: number) => {
|
||||
contextValue.progress = newProgress
|
||||
progress = newProgress
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue