File tree Expand file tree Collapse file tree
skins/base/views/organisms
src/controllers/organisms Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,13 +45,29 @@ module.exports = React.createClass({
4545 } ,
4646
4747 render : function ( ) {
48- return (
49- < div className = "mx_CreateRoom" >
50- < label > Room Name < RoomNameTextbox ref = "name_textbox" /> </ label >
51- < Presets ref = "presets" />
52- < UserSelector ref = "user_selector" />
53- < CreateRoomButton onCreateRoom = { this . onCreateRoom } />
54- </ div >
55- ) ;
48+ var curr_phase = this . state . phase ;
49+ if ( curr_phase == this . phases . CREATING ) {
50+ return (
51+ < div > Creating...</ div >
52+ ) ;
53+ } else {
54+ var error_box = "" ;
55+ if ( curr_phase == this . phases . ERROR ) {
56+ error_box = (
57+ < div className = "mx_Error" >
58+ An error occured: { this . state . error_string }
59+ </ div >
60+ ) ;
61+ }
62+ return (
63+ < div className = "mx_CreateRoom" >
64+ < label > Room Name < RoomNameTextbox ref = "name_textbox" /> </ label >
65+ < Presets ref = "presets" />
66+ < UserSelector ref = "user_selector" />
67+ < CreateRoomButton onCreateRoom = { this . onCreateRoom } />
68+ { error_box }
69+ </ div >
70+ ) ;
71+ }
5672 }
5773} ) ;
Original file line number Diff line number Diff line change @@ -24,12 +24,26 @@ module.exports = {
2424 onRoomCreated : React . PropTypes . func ,
2525 } ,
2626
27+ phases : {
28+ CONFIG : "CONFIG" ,
29+ CREATING : "CREATING" ,
30+ CREATED : "CREATED" ,
31+ ERROR : "ERROR" ,
32+ } ,
33+
2734 getDefaultProps : function ( ) {
2835 return {
2936 onRoomCreated : function ( ) { } ,
3037 } ;
3138 } ,
3239
40+ getInitialState : function ( ) {
41+ return {
42+ phase : this . phases . CONFIG ,
43+ error_string : "" ,
44+ } ;
45+ } ,
46+
3347 onCreateRoom : function ( ) {
3448 var options = { } ;
3549
@@ -57,8 +71,22 @@ module.exports = {
5771
5872 var deferred = MatrixClientPeg . get ( ) . createRoom ( options ) ;
5973
60- deferred . done ( function ( ) {
61- this . props . onRoomCreated ( ) ;
74+ this . setState ( {
75+ phase : this . phases . CREATING ,
76+ } ) ;
77+
78+ var self = this ;
79+
80+ deferred . then ( function ( ) {
81+ self . setState ( {
82+ phase : self . phases . CREATED ,
83+ } ) ;
84+ self . props . onRoomCreated ( ) ;
85+ } , function ( err ) {
86+ self . setState ( {
87+ phase : self . phases . ERROR ,
88+ error_string : err . toString ( ) ,
89+ } ) ;
6290 } ) ;
6391 }
6492} ;
You can’t perform that action at this time.
0 commit comments