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 bug where upload progress was not shown in FormAttachmentPopups #954

Merged
merged 1 commit into from
Mar 12, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/components/form-attachment/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ except according to the terms contained in the LICENSE file.

<script>
import { any } from 'ramda';
import { markRaw } from 'vue';

import DocLink from '../doc-link.vue';
import FileDropZone from '../file-drop-zone.vue';
Expand Down Expand Up @@ -147,7 +146,8 @@ export default {
- total. The total number of files to upload.
- remaining. The number of files that have not been uploaded yet.
- current. The name of the file currently being uploaded.
- progress. The latest ProgressEvent for the current upload.
- progress. The upload progress for the current upload as a
fraction.
4. Properties set once the uploads have finished or stopped and reset
once a new drag is started or another file input selection is made
- updatedAttachments. A Set of the names of the attachments for which
Expand All @@ -161,7 +161,7 @@ export default {
total: 0,
remaining: 0,
current: null,
progress: null
progress: 0
},
updatedAttachments: new Set(),
// Modals
Expand Down Expand Up @@ -286,7 +286,7 @@ export default {
// sync.
this.uploadStatus.remaining -= 1;
this.uploadStatus.current = file.name;
this.uploadStatus.progress = null;
this.uploadStatus.progress = 0;

return this.request({
method: 'POST',
Expand All @@ -300,8 +300,8 @@ export default {
'Content-Encoding': 'identity'
},
data: file,
onUploadProgress: (progressEvent) => {
this.uploadStatus.progress = markRaw(progressEvent);
onUploadProgress: (event) => {
this.uploadStatus.progress = event.progress ?? 0;
},
problemToAlert: (problem) => {
const { total } = this.uploadStatus;
Expand Down Expand Up @@ -356,7 +356,7 @@ export default {
this.updatedAttachments.add(name);
}
});
this.uploadStatus = { total: 0, remaining: 0, current: null, progress: null };
this.uploadStatus = { total: 0, remaining: 0, current: null, progress: 0 };
});
this.plannedUploads = [];
this.unmatchedFiles = [];
Expand Down
6 changes: 1 addition & 5 deletions src/components/form-attachment/popups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ export default {
this.shownDuringUpload;
},
percentUploaded() {
const { progress } = this.uploadStatus;
const fraction = progress != null && progress.lengthComputable
? progress.loaded / progress.total
: 0;
return this.$n(fraction, 'percent');
return this.$n(this.uploadStatus.progress, 'percent');
}
},
updated() {
Expand Down