Skip to content

Commit

Permalink
@uppy/xhr-upload: refactor to use fetcher (#5074)
Browse files Browse the repository at this point in the history
* @uppy/utils: add fetcher

* Improve callbacks

* Refactor local file uploads

* Refactor bundle upload

* Pass timeout to timeout handler

* Remove unused nanoid

* Apply feedback

* Prettier unrelated files

---------

Co-authored-by: Antoine du Hamel <antoine@transloadit.com>
  • Loading branch information
Murderlon and aduh95 authored Apr 29, 2024
1 parent 1b179a6 commit daae9aa
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 261 deletions.
5 changes: 3 additions & 2 deletions packages/@uppy/utils/src/ProgressTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ class ProgressTimeout {

constructor(
timeout: number,
timeoutHandler: Parameters<typeof setTimeout>[0],
// eslint-disable-next-line no-shadow
timeoutHandler: (timeout: number) => void,
) {
this.#timeout = timeout
this.#onTimedOut = timeoutHandler
this.#onTimedOut = () => timeoutHandler(timeout)
}

progress(): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/utils/src/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type FetcherOptions = {
) => void | Promise<void>

/** Called when no XMLHttpRequest upload progress events have been received for `timeout` ms. */
onTimeout?: () => void
onTimeout?: (timeout: number) => void

/** Signal to abort the upload. */
signal?: AbortSignal
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/xhr-upload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
},
"dependencies": {
"@uppy/companion-client": "workspace:^",
"@uppy/utils": "workspace:^",
"nanoid": "^4.0.0"
"@uppy/utils": "workspace:^"
},
"devDependencies": {
"nock": "^13.1.0",
Expand Down
Loading

0 comments on commit daae9aa

Please sign in to comment.