Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 92d1a9a

Browse files
committed
enable useCompactLayout user setting an add a class when it's enabled
Signed-off-by: Hubert Chathi <[email protected]>
1 parent 5781275 commit 92d1a9a

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

src/components/structures/LoggedInView.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ limitations under the License.
1818
import * as Matrix from 'matrix-js-sdk';
1919
import React from 'react';
2020

21+
import UserSettingsStore from '../../UserSettingsStore';
2122
import KeyCode from '../../KeyCode';
2223
import Notifier from '../../Notifier';
2324
import PageTypes from '../../PageTypes';
@@ -63,6 +64,13 @@ export default React.createClass({
6364
};
6465
},
6566

67+
getInitialState: function() {
68+
return {
69+
// use compact timeline view
70+
useCompactLayout: UserSettingsStore.getSyncedSetting('useCompactLayout'),
71+
};
72+
},
73+
6674
componentWillMount: function() {
6775
// stash the MatrixClient in case we log out before we are unmounted
6876
this._matrixClient = this.props.matrixClient;
@@ -72,10 +80,12 @@ export default React.createClass({
7280
this._scrollStateMap = {};
7381

7482
document.addEventListener('keydown', this._onKeyDown);
83+
this._matrixClient.on("accountData", this.onAccountData);
7584
},
7685

7786
componentWillUnmount: function() {
7887
document.removeEventListener('keydown', this._onKeyDown);
88+
this._matrixClient.removeListener("accountData", this.onAccountData);
7989
},
8090

8191
getScrollStateForRoom: function(roomId) {
@@ -89,6 +99,14 @@ export default React.createClass({
8999
return this.refs.roomView.canResetTimeline();
90100
},
91101

102+
onAccountData: function(event) {
103+
if (event.getType() === "im.vector.web.settings") {
104+
this.setState({
105+
useCompactLayout: event.getContent().useCompactLayout
106+
});
107+
}
108+
},
109+
92110
_onKeyDown: function(ev) {
93111
/*
94112
// 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({
245263
if (topBar) {
246264
bodyClasses += ' mx_MatrixChat_toolbarShowing';
247265
}
266+
if (this.state.useCompactLayout) {
267+
bodyClasses += ' mx_MatrixChat_useCompactLayout';
268+
}
248269

249270
return (
250271
<div className='mx_MatrixChat_wrapper'>

src/components/structures/UserSettings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ const SETTINGS_LABELS = [
7979
id: 'showTwelveHourTimestamps',
8080
label: 'Show timestamps in 12 hour format (e.g. 2:30pm)',
8181
},
82-
/*
8382
{
8483
id: 'useCompactLayout',
8584
label: 'Use compact timeline layout',
8685
},
86+
/*
8787
{
8888
id: 'useFixedWidthFont',
8989
label: 'Use fixed width font',

src/i18n/strings/en_EN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@
517517
"Upload Files": "Upload Files",
518518
"Upload file": "Upload file",
519519
"Usage": "Usage",
520+
"Use compact timeline layout": "Use compact timeline layout",
520521
"Use with caution": "Use with caution",
521522
"User ID": "User ID",
522523
"User Interface": "User Interface",

0 commit comments

Comments
 (0)