mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-18 07:12:58 +03:00
Merge pull request #3066 from matrix-org/travis/no-button-guest
Add a logged in class to EmbeddedPage and react to MatrixClient changes
This commit is contained in:
commit
38a4031299
1 changed files with 15 additions and 1 deletions
|
@ -24,6 +24,8 @@ import request from 'browser-request';
|
||||||
import { _t } from '../../languageHandler';
|
import { _t } from '../../languageHandler';
|
||||||
import sanitizeHtml from 'sanitize-html';
|
import sanitizeHtml from 'sanitize-html';
|
||||||
import sdk from '../../index';
|
import sdk from '../../index';
|
||||||
|
import dis from '../../dispatcher';
|
||||||
|
import MatrixClientPeg from '../../MatrixClientPeg';
|
||||||
import { MatrixClient } from 'matrix-js-sdk';
|
import { MatrixClient } from 'matrix-js-sdk';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
|
||||||
|
@ -82,19 +84,31 @@ export default class EmbeddedPage extends React.PureComponent {
|
||||||
this.setState({ page: body });
|
this.setState({ page: body });
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._dispatcherRef = dis.register(this.onAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this._unmounted = true;
|
this._unmounted = true;
|
||||||
|
dis.unregister(this._dispatcherRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onAction = (payload) => {
|
||||||
|
// HACK: Workaround for the context's MatrixClient not being set up at render time.
|
||||||
|
if (payload.action === 'client_started') {
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const client = this.context.matrixClient;
|
// HACK: Workaround for the context's MatrixClient not updating.
|
||||||
|
const client = this.context.matrixClient || MatrixClientPeg.get();
|
||||||
const isGuest = client ? client.isGuest() : true;
|
const isGuest = client ? client.isGuest() : true;
|
||||||
const className = this.props.className;
|
const className = this.props.className;
|
||||||
const classes = classnames({
|
const classes = classnames({
|
||||||
[className]: true,
|
[className]: true,
|
||||||
[`${className}_guest`]: isGuest,
|
[`${className}_guest`]: isGuest,
|
||||||
|
[`${className}_loggedIn`]: !!client,
|
||||||
});
|
});
|
||||||
|
|
||||||
const content = <div className={`${className}_body`}
|
const content = <div className={`${className}_body`}
|
||||||
|
|
Loading…
Reference in a new issue