@@ -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