Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Nov 11, 2024
1 parent 633e401 commit e3b2a1f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
1 change: 0 additions & 1 deletion packages/@uppy/companion-client/src/RequestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ function emitSocketProgress(
}
}


export default class RequestClient<M extends Meta, B extends Body> {
static VERSION = packageJson.version

Expand Down
25 changes: 16 additions & 9 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,11 @@ export class Uppy<
isUploadInProgress: boolean
isSomeGhost: boolean
} {
const { files: filesObject, progress: totalProgress, error } = this.getState()
const {
files: filesObject,
progress: totalProgress,
error,
} = this.getState()
const files = Object.values(filesObject)

const inProgressFiles: UppyFile<M, B>[] = []
Expand Down Expand Up @@ -1472,7 +1476,7 @@ export class Uppy<

#updateTotalProgress() {
const totalProgress = this.#calculateTotalProgress()
let totalProgressPercent: number | null = null;
let totalProgressPercent: number | null = null
if (totalProgress != null) {
totalProgressPercent = Math.round(totalProgress * 100)
if (totalProgressPercent > 100) totalProgressPercent = 100
Expand Down Expand Up @@ -1522,7 +1526,8 @@ export class Uppy<
}

const sizedFilesInProgress = filesInProgress.filter(
(file) => file.progress.bytesTotal != null && file.progress.bytesTotal !== 0,
(file) =>
file.progress.bytesTotal != null && file.progress.bytesTotal !== 0,
)

if (sizedFilesInProgress.length === 0) {
Expand All @@ -1539,13 +1544,15 @@ export class Uppy<
return null
}

const totalFilesSize = sizedFilesInProgress.reduce((acc, file) => (
acc + (file.progress.bytesTotal ?? 0)
), 0)
const totalFilesSize = sizedFilesInProgress.reduce(
(acc, file) => acc + (file.progress.bytesTotal ?? 0),
0,
)

const totalUploadedSize = sizedFilesInProgress.reduce((acc, file) => (
acc + (file.progress.bytesUploaded || 0)
), 0)
const totalUploadedSize = sizedFilesInProgress.reduce(
(acc, file) => acc + (file.progress.bytesUploaded || 0),
0,
)

return totalFilesSize === 0 ? 0 : totalUploadedSize / totalFilesSize
}
Expand Down
3 changes: 2 additions & 1 deletion packages/@uppy/progress-bar/src/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export default class ProgressBar<
const { progress } = state
// before starting and after finish should be hidden if specified in the options
const isHidden =
(progress == null || progress === 0 || progress === 100) && this.opts.hideAfterFinish
(progress == null || progress === 0 || progress === 100) &&
this.opts.hideAfterFinish
return (
<div
className="uppy uppy-ProgressBar"
Expand Down
22 changes: 13 additions & 9 deletions packages/@uppy/status-bar/src/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ function ProgressDetails(props: ProgressDetailsProps) {

const totalUploadedSizeStr = prettierBytes(totalUploadedSize)


return (
<div className="uppy-StatusBar-statusSecondary">
{ifShowFilesUploadedOfTotal &&
Expand All @@ -292,16 +291,19 @@ function ProgressDetails(props: ProgressDetailsProps) {
*/}
{ifShowFilesUploadedOfTotal && renderDot()}

{totalSize !== 0 ? i18n('dataUploadedOfTotal', {
complete: totalUploadedSizeStr,
total: prettierBytes(totalSize),
}) : totalUploadedSizeStr}
{totalSize !== 0 ?
i18n('dataUploadedOfTotal', {
complete: totalUploadedSizeStr,
total: prettierBytes(totalSize),
})
: totalUploadedSizeStr}

{renderDot()}

{totalETA != null && i18n('xTimeLeft', {
time: prettyETA(totalETA),
})}
{totalETA != null &&
i18n('xTimeLeft', {
time: prettyETA(totalETA),
})}
</span>
</div>
)
Expand Down Expand Up @@ -430,7 +432,9 @@ function ProgressBarUploading(props: ProgressBarUploadingProps) {
: null}
<div className="uppy-StatusBar-status">
<div className="uppy-StatusBar-statusPrimary">
{supportsUploadProgress && totalProgress != null ? `${title}: ${totalProgress}%` : title}
{supportsUploadProgress && totalProgress != null ?
`${title}: ${totalProgress}%`
: title}
</div>

{renderProgressDetails()}
Expand Down
6 changes: 5 additions & 1 deletion packages/@uppy/status-bar/src/StatusBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ export default class StatusBar<M extends Meta, B extends Body> extends UIPlugin<
let totalUploadedSize = 0

// If at least one file has an unknown size, it doesn't make sense to display a total size
if (startedFiles.every((f) => f.progress.bytesTotal != null && f.progress.bytesTotal !== 0)) {
if (
startedFiles.every(
(f) => f.progress.bytesTotal != null && f.progress.bytesTotal !== 0,
)
) {
startedFiles.forEach((file) => {
totalSize += file.progress.bytesTotal || 0
totalUploadedSize += file.progress.bytesUploaded || 0
Expand Down

0 comments on commit e3b2a1f

Please sign in to comment.