@@ -26,11 +26,18 @@ export default class BugReportDialog extends React.Component {
2626 busy : false ,
2727 err : null ,
2828 text : "" ,
29+ progress : null ,
2930 } ;
31+ this . _unmounted = false ;
3032 this . _onSubmit = this . _onSubmit . bind ( this ) ;
3133 this . _onCancel = this . _onCancel . bind ( this ) ;
3234 this . _onTextChange = this . _onTextChange . bind ( this ) ;
3335 this . _onSendLogsChange = this . _onSendLogsChange . bind ( this ) ;
36+ this . _sendProgressCallback = this . _sendProgressCallback . bind ( this ) ;
37+ }
38+
39+ componentWillUnmount ( ) {
40+ this . _unmounted = true ;
3441 }
3542
3643 _onCancel ( ev ) {
@@ -46,17 +53,22 @@ export default class BugReportDialog extends React.Component {
4653 } ) ;
4754 return ;
4855 }
49- this . setState ( { busy : true , err : null } ) ;
56+ this . setState ( { busy : true , progress : null , err : null } ) ;
57+ this . _sendProgressCallback ( "Loading bug report module" ) ;
5058
5159 require ( [ '../../../vector/submit-rageshake' ] , ( s ) => {
5260 s ( SdkConfig . get ( ) . bug_report_endpoint_url , {
5361 userText : userText ,
5462 sendLogs : sendLogs ,
63+ progressCallback : this . _sendProgressCallback ,
5564 } ) . then ( ( ) => {
56- this . setState ( { busy : false } ) ;
65+ this . setState ( { busy : false , progress : null } ) ;
5766 this . props . onFinished ( false ) ;
5867 } , ( err ) => {
59- this . setState ( { busy : false , err : `Failed: ${ err . message } ` } ) ;
68+ this . setState ( {
69+ busy : false , progress : null ,
70+ err : `Failed to send report: ${ err . message } ` ,
71+ } ) ;
6072 } ) ;
6173 } ) ;
6274 }
@@ -69,6 +81,13 @@ export default class BugReportDialog extends React.Component {
6981 this . setState ( { sendLogs : ev . target . checked } ) ;
7082 }
7183
84+ _sendProgressCallback ( progress ) {
85+ if ( this . _unmounted ) {
86+ return ;
87+ }
88+ this . setState ( { progress : progress } ) ;
89+ }
90+
7291 render ( ) {
7392 const Loader = sdk . getComponent ( "elements.Spinner" ) ;
7493
@@ -79,15 +98,23 @@ export default class BugReportDialog extends React.Component {
7998 </ div > ;
8099 }
81100
82- const okLabel = this . state . busy ? < Loader /> : 'Send' ;
83-
84101 let cancelButton = null ;
85102 if ( ! this . state . busy ) {
86103 cancelButton = < button onClick = { this . _onCancel } >
87104 Cancel
88105 </ button > ;
89106 }
90107
108+ let progress = null ;
109+ if ( this . state . busy ) {
110+ progress = (
111+ < div className = "progress" >
112+ < Loader />
113+ { this . state . progress } ...
114+ </ div >
115+ ) ;
116+ }
117+
91118 return (
92119 < div className = "mx_BugReportDialog" >
93120 < div className = "mx_Dialog_title" >
@@ -110,15 +137,17 @@ export default class BugReportDialog extends React.Component {
110137 < input type = "checkbox" checked = { this . state . sendLogs }
111138 onChange = { this . _onSendLogsChange } id = "mx_BugReportDialog_logs" />
112139 < label htmlFor = "mx_BugReportDialog_logs" > Send logs</ label >
140+ { progress }
113141 { error }
114142 </ div >
115143 < div className = "mx_Dialog_buttons" >
116144 < button
117145 className = "mx_Dialog_primary danger"
118146 onClick = { this . _onSubmit }
119147 autoFocus = { true }
148+ disabled = { this . state . busy }
120149 >
121- { okLabel }
150+ Send
122151 </ button >
123152
124153 { cancelButton }
0 commit comments