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: set initial progress to 0 #368

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

kontrollanten
Copy link
Contributor

For convenient usage, set initial progress to 0 to let the consumer to skip to check if progress isn't NaN.

Copy link
Owner

@kukhariev kukhariev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

progress = 0

src/uploadx/lib/uploader.ts Outdated Show resolved Hide resolved
@kukhariev kukhariev changed the title Set initial progress to 0 fix: set initial progress to 0 Apr 7, 2022
@kukhariev kukhariev merged commit f724ee3 into kukhariev:master Apr 7, 2022
@kontrollanten kontrollanten deleted the prevent-nan branch April 8, 2022 04:40
@Chocobozzz
Copy link

offset should also be initialized to not have NaN in uploading state

@kukhariev
Copy link
Owner

@Chocobozzz
I'm not sure to understand: offset: number | undefined is internal, not a member of UploadState.

export const UPLOAD_STATE_KEYS: (keyof UploadState)[] = [
'file',
'name',
'progress',
'remaining',
'response',
'responseHeaders',
'responseStatus',
'size',
'speed',
'status',
'uploadId',
'url'
];

@Chocobozzz
Copy link

@kukhariev It's used to calculate progress: https://github.com/kukhariev/ngx-uploadx/blob/master/src/uploadx/lib/uploader.ts#L280

And undefined + 30 = NaN so we still have a NaN for the first progress state

@kukhariev
Copy link
Owner

Thanks!, should be fixed by #374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants