mirror of https://github.com/vector-im/riot-web
Fix upload bar not populating when starting uploads
Fixes https://github.com/vector-im/element-web/issues/16713 See diff for more informationpull/21833/head
parent
318db15e35
commit
76a05eddfa
|
@ -43,7 +43,11 @@ export default class UploadBar extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {uploadsHere: []};
|
|
||||||
|
// Set initial state to any available upload in this room - we might be mounting
|
||||||
|
// earlier than the first progress event, so should show something relevant.
|
||||||
|
const uploadsHere = this.getUploadsInRoom();
|
||||||
|
this.state = {currentUpload: uploadsHere[0], uploadsHere};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -56,6 +60,11 @@ export default class UploadBar extends React.Component<IProps, IState> {
|
||||||
dis.unregister(this.dispatcherRef);
|
dis.unregister(this.dispatcherRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getUploadsInRoom(): IUpload[] {
|
||||||
|
const uploads = ContentMessages.sharedInstance().getCurrentUploads();
|
||||||
|
return uploads.filter(u => u.roomId === this.props.room.roomId);
|
||||||
|
}
|
||||||
|
|
||||||
private onAction = (payload: ActionPayload) => {
|
private onAction = (payload: ActionPayload) => {
|
||||||
switch (payload.action) {
|
switch (payload.action) {
|
||||||
case Action.UploadStarted:
|
case Action.UploadStarted:
|
||||||
|
@ -64,8 +73,7 @@ export default class UploadBar extends React.Component<IProps, IState> {
|
||||||
case Action.UploadCanceled:
|
case Action.UploadCanceled:
|
||||||
case Action.UploadFailed: {
|
case Action.UploadFailed: {
|
||||||
if (!this.mounted) return;
|
if (!this.mounted) return;
|
||||||
const uploads = ContentMessages.sharedInstance().getCurrentUploads();
|
const uploadsHere = this.getUploadsInRoom();
|
||||||
const uploadsHere = uploads.filter(u => u.roomId === this.props.room.roomId);
|
|
||||||
this.setState({currentUpload: uploadsHere[0], uploadsHere});
|
this.setState({currentUpload: uploadsHere[0], uploadsHere});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue