mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 17:56:01 +03:00
Clean up and follow code style
This commit is contained in:
parent
7b0766a303
commit
ef60a34180
3 changed files with 29 additions and 36 deletions
|
@ -35,7 +35,6 @@ limitations under the License.
|
|||
.mx_RoomTile_nameContainer {
|
||||
display: inline-block;
|
||||
width: 180px;
|
||||
//height: 24px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,22 @@ import classNames from 'classnames';
|
|||
import * as ContextualMenu from "../../structures/ContextualMenu";
|
||||
import StatusMessageContextMenu from "../context_menus/StatusMessageContextMenu";
|
||||
|
||||
export default class MemberStatusMessageAvatar extends React.Component {
|
||||
export default class MemberStatusMessageAvatar extends React.PureComponent {
|
||||
static propTypes = {
|
||||
member: PropTypes.object.isRequired,
|
||||
width: PropTypes.number,
|
||||
height: PropTypes.number,
|
||||
resizeMethod: PropTypes.string,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
width: 40,
|
||||
height: 40,
|
||||
resizeMethod: 'crop',
|
||||
};
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this._onRoomStateEvents = this._onRoomStateEvents.bind(this);
|
||||
this._onClick = this._onClick.bind(this);
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
|
@ -52,15 +63,14 @@ export default class MemberStatusMessageAvatar extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
_onRoomStateEvents(ev, state) {
|
||||
_onRoomStateEvents = (ev, state) => {
|
||||
if (ev.getStateKey() !== MatrixClientPeg.get().getUserId()) return;
|
||||
if (ev.getType() !== "im.vector.user_status") return;
|
||||
// TODO: We should be relying on `this.props.member.user._unstable_statusMessage`
|
||||
this.setState({message: ev.getContent()["status"]});
|
||||
this.forceUpdate();
|
||||
}
|
||||
};
|
||||
|
||||
_onClick(e) {
|
||||
_onClick = (e) => {
|
||||
e.stopPropagation();
|
||||
|
||||
const elementRect = e.target.getBoundingClientRect();
|
||||
|
@ -79,7 +89,7 @@ export default class MemberStatusMessageAvatar extends React.Component {
|
|||
menuWidth: 190,
|
||||
user: this.props.member.user,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const hasStatus = this.props.member.user ? !!this.props.member.user._unstable_statusMessage : false;
|
||||
|
@ -97,16 +107,3 @@ export default class MemberStatusMessageAvatar extends React.Component {
|
|||
</AccessibleButton>;
|
||||
}
|
||||
}
|
||||
|
||||
MemberStatusMessageAvatar.propTypes = {
|
||||
member: PropTypes.object.isRequired,
|
||||
width: PropTypes.number,
|
||||
height: PropTypes.number,
|
||||
resizeMethod: PropTypes.string,
|
||||
};
|
||||
|
||||
MemberStatusMessageAvatar.defaultProps = {
|
||||
width: 40,
|
||||
height: 40,
|
||||
resizeMethod: 'crop',
|
||||
};
|
||||
|
|
|
@ -22,30 +22,32 @@ import AccessibleButton from '../elements/AccessibleButton';
|
|||
import classNames from 'classnames';
|
||||
|
||||
export default class StatusMessageContextMenu extends React.Component {
|
||||
static propTypes = {
|
||||
// js-sdk User object. Not required because it might not exist.
|
||||
user: PropTypes.object,
|
||||
};
|
||||
|
||||
constructor(props, context) {
|
||||
super(props, context);
|
||||
this._onClearClick = this._onClearClick.bind(this);
|
||||
this._onSubmit = this._onSubmit.bind(this);
|
||||
this._onStatusChange = this._onStatusChange.bind(this);
|
||||
|
||||
this.state = {
|
||||
message: props.user ? props.user._unstable_statusMessage : "",
|
||||
};
|
||||
}
|
||||
|
||||
async _onClearClick(e) {
|
||||
_onClearClick = async (e) => {
|
||||
await MatrixClientPeg.get()._unstable_setStatusMessage("");
|
||||
this.setState({message: ""});
|
||||
}
|
||||
};
|
||||
|
||||
_onSubmit(e) {
|
||||
_onSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
MatrixClientPeg.get()._unstable_setStatusMessage(this.state.message);
|
||||
}
|
||||
};
|
||||
|
||||
_onStatusChange(e) {
|
||||
_onStatusChange = (e) => {
|
||||
this.setState({message: e.target.value});
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const formSubmitClasses = classNames({
|
||||
|
@ -82,8 +84,3 @@ export default class StatusMessageContextMenu extends React.Component {
|
|||
</div>;
|
||||
}
|
||||
}
|
||||
|
||||
StatusMessageContextMenu.propTypes = {
|
||||
// js-sdk User object. Not required because it might not exist.
|
||||
user: PropTypes.object,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue