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

enable useCompactLayout user setting an add a class when it's enabled #986

Merged
merged 1 commit into from
Jun 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/components/structures/LoggedInView.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
import * as Matrix from 'matrix-js-sdk';
import React from 'react';

import UserSettingsStore from '../../UserSettingsStore';
import KeyCode from '../../KeyCode';
import Notifier from '../../Notifier';
import PageTypes from '../../PageTypes';
Expand Down Expand Up @@ -63,6 +64,13 @@ export default React.createClass({
};
},

getInitialState: function() {
return {
// use compact timeline view
useCompactLayout: UserSettingsStore.getSyncedSetting('useCompactLayout'),
};
},

componentWillMount: function() {
// stash the MatrixClient in case we log out before we are unmounted
this._matrixClient = this.props.matrixClient;
Expand All @@ -72,10 +80,12 @@ export default React.createClass({
this._scrollStateMap = {};

document.addEventListener('keydown', this._onKeyDown);
this._matrixClient.on("accountData", this.onAccountData);
},

componentWillUnmount: function() {
document.removeEventListener('keydown', this._onKeyDown);
this._matrixClient.removeListener("accountData", this.onAccountData);
},

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

onAccountData: function(event) {
if (event.getType() === "im.vector.web.settings") {
this.setState({
useCompactLayout: event.getContent().useCompactLayout
});
}
},

_onKeyDown: function(ev) {
/*
// Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers
Expand Down Expand Up @@ -245,6 +263,9 @@ export default React.createClass({
if (topBar) {
bodyClasses += ' mx_MatrixChat_toolbarShowing';
}
if (this.state.useCompactLayout) {
bodyClasses += ' mx_MatrixChat_useCompactLayout';
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is now getting a little more complex any chance you could pleez incorporate classnames
e.g like here

const labelClasses = classNames({


return (
<div className='mx_MatrixChat_wrapper'>
Expand Down
2 changes: 1 addition & 1 deletion src/components/structures/UserSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ const SETTINGS_LABELS = [
id: 'showTwelveHourTimestamps',
label: 'Show timestamps in 12 hour format (e.g. 2:30pm)',
},
/*
{
id: 'useCompactLayout',
label: 'Use compact timeline layout',
},
/*
{
id: 'useFixedWidthFont',
label: 'Use fixed width font',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@
"Upload Files": "Upload Files",
"Upload file": "Upload file",
"Usage": "Usage",
"Use compact timeline layout": "Use compact timeline layout",
"Use with caution": "Use with caution",
"User ID": "User ID",
"User Interface": "User Interface",
Expand Down