Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix various type issues #4958

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import locale from './locale.ts'

import type BasePlugin from './BasePlugin.ts'
import type UIPlugin from './UIPlugin.ts'

Check warning on line 50 in packages/@uppy/core/src/Uppy.ts

View workflow job for this annotation

GitHub Actions / Lint JavaScript/TypeScript

'UIPlugin' is defined but never used
import type { Restrictions, ValidateableFile } from './Restricter.ts'

type Processor = (fileIDs: string[], uploadID: string) => Promise<void> | void
Expand Down Expand Up @@ -942,7 +942,7 @@
bytesTotal: size,
uploadComplete: false,
uploadStarted: null,
} as FileProgressNotStarted,
} satisfies FileProgressNotStarted,
size,
isGhost: false,
isRemote: file.isRemote || false,
Expand Down Expand Up @@ -1377,6 +1377,8 @@
// and click 'ADD MORE FILES', - focus won't activate in Firefox.
// - We must throttle at around >500ms to avoid performance lags.
// [Practical Check] Firefox, try to upload a big file for a prolonged period of time. Laptop will start to heat up.
// todo when uploading multiple files, this will cause problems because they share the same throttle,
// meaning some files might never get their progress reported (eaten up by progress events from other files)
calculateProgress = throttle(
(file, data) => {
const fileInState = this.getFile(file?.id)
Expand Down Expand Up @@ -1559,7 +1561,6 @@
file.id,
{
progress: {
progress: 0,
uploadStarted: Date.now(),
uploadComplete: false,
percentage: 0,
Expand Down
4 changes: 1 addition & 3 deletions packages/@uppy/utils/src/FileProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ export type FileProcessingInfo =
| DeterminateFileProcessing

interface FileProgressBase {
progress?: number
uploadComplete?: boolean
percentage?: number
bytesTotal: number
bytesTotal: number | null
preprocess?: FileProcessingInfo
postprocess?: FileProcessingInfo
}
Expand All @@ -26,7 +25,6 @@ interface FileProgressBase {
export type FileProgressStarted = FileProgressBase & {
uploadStarted: number
bytesUploaded: number
progress?: number
}
export type FileProgressNotStarted = FileProgressBase & {
uploadStarted: null
Expand Down
9 changes: 7 additions & 2 deletions packages/@uppy/utils/src/emitSocketProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ import type { FileProgress } from './FileProgress'

function emitSocketProgress(
uploader: any,
progressData: FileProgress,
progressData: {
progress: string // pre-formatted percentage
bytesTotal: number
bytesUploaded: number
},
file: UppyFile<any, any>,
): void {
const { progress, bytesUploaded, bytesTotal } = progressData
if (progress) {
uploader.uppy.log(`Upload progress: ${progress}`)
uploader.uppy.emit('upload-progress', file, {
// @ts-expect-error todo remove in next major
uploader,
bytesUploaded,
bytesTotal,
})
} satisfies FileProgress)
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/utils/src/getBytesRemaining.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { FileProgress } from './FileProgress'

export default function getBytesRemaining(fileProgress: FileProgress): number {
if (fileProgress.bytesTotal == null) return 0
return fileProgress.bytesTotal - (fileProgress.bytesUploaded as number)
}