@@ -31,6 +31,43 @@ module.exports = React.createClass({
3131 displayName : 'MatrixChat' ,
3232 mixins : [ MatrixChatController ] ,
3333
34+ getInitialState : function ( ) {
35+ return {
36+ width : 10000 ,
37+ }
38+ } ,
39+
40+ componentDidMount : function ( ) {
41+ window . addEventListener ( 'resize' , this . handleResize ) ;
42+ this . handleResize ( ) ;
43+ } ,
44+
45+ componentWillUnmount : function ( ) {
46+ window . removeEventListener ( 'resize' , this . handleResize ) ;
47+ } ,
48+
49+ handleResize : function ( e ) {
50+ var hideLhsThreshold = 1000 ;
51+ var showLhsThreshold = 1000 ;
52+ var hideRhsThreshold = 820 ;
53+ var showRhsThreshold = 820 ;
54+
55+ if ( this . state . width > hideLhsThreshold && window . innerWidth <= hideLhsThreshold ) {
56+ dis . dispatch ( { action : 'hide_left_panel' } ) ;
57+ }
58+ if ( this . state . width <= showLhsThreshold && window . innerWidth > showLhsThreshold ) {
59+ dis . dispatch ( { action : 'show_left_panel' } ) ;
60+ }
61+ if ( this . state . width > hideRhsThreshold && window . innerWidth <= hideRhsThreshold ) {
62+ dis . dispatch ( { action : 'hide_right_panel' } ) ;
63+ }
64+ if ( this . state . width <= showRhsThreshold && window . innerWidth > showRhsThreshold ) {
65+ dis . dispatch ( { action : 'show_right_panel' } ) ;
66+ }
67+
68+ this . setState ( { width : window . innerWidth } ) ;
69+ } ,
70+
3471 onRoomCreated : function ( room_id ) {
3572 dis . dispatch ( {
3673 action : "view_room" ,
@@ -57,19 +94,19 @@ module.exports = React.createClass({
5794 switch ( this . state . page_type ) {
5895 case this . PageTypes . RoomView :
5996 page_element = < RoomView roomId = { this . state . currentRoom } key = { this . state . currentRoom } />
60- right_panel = < RightPanel roomId = { this . state . currentRoom } />
97+ right_panel = < RightPanel roomId = { this . state . currentRoom } collapsed = { this . state . collapse_rhs } />
6198 break ;
6299 case this . PageTypes . UserSettings :
63100 page_element = < UserSettings />
64- right_panel = < RightPanel />
101+ right_panel = < RightPanel collapsed = { this . state . collapse_rhs } />
65102 break ;
66103 case this . PageTypes . CreateRoom :
67104 page_element = < CreateRoom onRoomCreated = { this . onRoomCreated } />
68- right_panel = < RightPanel />
105+ right_panel = < RightPanel collapsed = { this . state . collapse_rhs } />
69106 break ;
70107 case this . PageTypes . RoomDirectory :
71108 page_element = < RoomDirectory />
72- right_panel = < RightPanel />
109+ right_panel = < RightPanel collapsed = { this . state . collapse_rhs } />
73110 break ;
74111 }
75112
0 commit comments