@@ -18,6 +18,7 @@ limitations under the License.
18
18
import * as Matrix from 'matrix-js-sdk' ;
19
19
import React from 'react' ;
20
20
21
+ import UserSettingsStore from '../../UserSettingsStore' ;
21
22
import KeyCode from '../../KeyCode' ;
22
23
import Notifier from '../../Notifier' ;
23
24
import PageTypes from '../../PageTypes' ;
@@ -63,6 +64,13 @@ export default React.createClass({
63
64
} ;
64
65
} ,
65
66
67
+ getInitialState : function ( ) {
68
+ return {
69
+ // use compact timeline view
70
+ useCompactLayout : UserSettingsStore . getSyncedSetting ( 'useCompactLayout' ) ,
71
+ } ;
72
+ } ,
73
+
66
74
componentWillMount : function ( ) {
67
75
// stash the MatrixClient in case we log out before we are unmounted
68
76
this . _matrixClient = this . props . matrixClient ;
@@ -72,10 +80,12 @@ export default React.createClass({
72
80
this . _scrollStateMap = { } ;
73
81
74
82
document . addEventListener ( 'keydown' , this . _onKeyDown ) ;
83
+ this . _matrixClient . on ( "accountData" , this . onAccountData ) ;
75
84
} ,
76
85
77
86
componentWillUnmount : function ( ) {
78
87
document . removeEventListener ( 'keydown' , this . _onKeyDown ) ;
88
+ this . _matrixClient . removeListener ( "accountData" , this . onAccountData ) ;
79
89
} ,
80
90
81
91
getScrollStateForRoom : function ( roomId ) {
@@ -89,6 +99,14 @@ export default React.createClass({
89
99
return this . refs . roomView . canResetTimeline ( ) ;
90
100
} ,
91
101
102
+ onAccountData : function ( event ) {
103
+ if ( event . getType ( ) === "im.vector.web.settings" ) {
104
+ this . setState ( {
105
+ useCompactLayout : event . getContent ( ) . useCompactLayout
106
+ } ) ;
107
+ }
108
+ } ,
109
+
92
110
_onKeyDown : function ( ev ) {
93
111
/*
94
112
// Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers
@@ -245,6 +263,9 @@ export default React.createClass({
245
263
if ( topBar ) {
246
264
bodyClasses += ' mx_MatrixChat_toolbarShowing' ;
247
265
}
266
+ if ( this . state . useCompactLayout ) {
267
+ bodyClasses += ' mx_MatrixChat_useCompactLayout' ;
268
+ }
248
269
249
270
return (
250
271
< div className = 'mx_MatrixChat_wrapper' >
0 commit comments