Skip to content

Commit 332e7d5

Browse files
authored
regression: Upload loading state relying on percentage instead of file URL (#39780)
1 parent d7325cd commit 332e7d5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

apps/meteor/client/lib/chats/uploads.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class UploadsStore extends Emitter<{ update: void; [x: `cancelling-${Upload['id'
152152
return;
153153
}
154154
const progress = (event.loaded / event.total) * 100;
155-
this.updateUpload(id, { percentage: Math.round(progress) || 0 });
155+
this.updateUpload(id, { percentage: Math.min(Math.round(progress), 99) || 0 });
156156
},
157157
error: (event) => {
158158
this.updateUpload(id, { percentage: 0, error: new Error(xhr.responseText) });
@@ -175,7 +175,7 @@ class UploadsStore extends Emitter<{ update: void; [x: `cancelling-${Upload['id'
175175

176176
if (xhr.status === 200) {
177177
const result = JSON.parse(xhr.responseText);
178-
this.updateUpload(id, { id: result.file._id, url: result.file.url });
178+
this.updateUpload(id, { id: result.file._id, url: result.file.url, percentage: 100 });
179179
return;
180180
}
181181

apps/meteor/client/views/room/body/hooks/useFileUpload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const useFileUpload = () => {
3333
[chat],
3434
);
3535

36-
const isUploading = uploads.length > 0 && uploads.some((upload) => upload.percentage < 100 && !upload.error);
36+
const isUploading = uploads.length > 0 && uploads.some((upload) => !upload.url && !upload.error);
3737

3838
return useMemo(
3939
() => ({

apps/meteor/client/views/room/composer/messageBox/MessageComposerFileItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const MessageComposerFileItem = ({ upload, onRemove, onEdit, onCancel, disabled,
2626

2727
const fileSize = formatBytes(upload.file.size, 2);
2828
const fileExtension = getMimeType(upload.file.type, upload.file.name);
29-
const isLoading = upload.percentage !== 100 && !upload.error;
29+
const isLoading = !upload.url && !upload.error;
3030

3131
const handleOpenFilePreview = () => {
3232
if (isLoading || upload.error) {

0 commit comments

Comments
 (0)