Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e48dbef

Browse files
authored
Merge pull request #5804 from matrix-org/travis/uploads-fix
Fix upload bar not populating when starting uploads
2 parents 22b7081 + 76a05ed commit e48dbef

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/components/structures/UploadBar.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ export default class UploadBar extends React.Component<IProps, IState> {
4343

4444
constructor(props) {
4545
super(props);
46-
this.state = {uploadsHere: []};
46+
47+
// Set initial state to any available upload in this room - we might be mounting
48+
// earlier than the first progress event, so should show something relevant.
49+
const uploadsHere = this.getUploadsInRoom();
50+
this.state = {currentUpload: uploadsHere[0], uploadsHere};
4751
}
4852

4953
componentDidMount() {
@@ -56,6 +60,11 @@ export default class UploadBar extends React.Component<IProps, IState> {
5660
dis.unregister(this.dispatcherRef);
5761
}
5862

63+
private getUploadsInRoom(): IUpload[] {
64+
const uploads = ContentMessages.sharedInstance().getCurrentUploads();
65+
return uploads.filter(u => u.roomId === this.props.room.roomId);
66+
}
67+
5968
private onAction = (payload: ActionPayload) => {
6069
switch (payload.action) {
6170
case Action.UploadStarted:
@@ -64,8 +73,7 @@ export default class UploadBar extends React.Component<IProps, IState> {
6473
case Action.UploadCanceled:
6574
case Action.UploadFailed: {
6675
if (!this.mounted) return;
67-
const uploads = ContentMessages.sharedInstance().getCurrentUploads();
68-
const uploadsHere = uploads.filter(u => u.roomId === this.props.room.roomId);
76+
const uploadsHere = this.getUploadsInRoom();
6977
this.setState({currentUpload: uploadsHere[0], uploadsHere});
7078
break;
7179
}

0 commit comments

Comments
 (0)