Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2018-06-16 09:10:13 +01:00
parent 8fa96e19d5
commit 4fdb64a049
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E

View file

@ -1,6 +1,7 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015, 2016 OpenMarket Ltd
Copyright 2017 New Vector Ltd Copyright 2017 New Vector Ltd
Copyright 2018 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,19 +16,17 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
'use strict';
const React = require('react'); import React from 'react';
const ReactDOM = require("react-dom");
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
const classNames = require('classnames'); import classNames from 'classnames';
import dis from '../../../dispatcher'; import dis from '../../../dispatcher';
const MatrixClientPeg = require('../../../MatrixClientPeg'); import MatrixClientPeg from '../../../MatrixClientPeg';
import DMRoomMap from '../../../utils/DMRoomMap'; import DMRoomMap from '../../../utils/DMRoomMap';
const sdk = require('../../../index'); import sdk from '../../../index';
const ContextualMenu = require('../../structures/ContextualMenu'); import ContextualMenu from '../../structures/ContextualMenu';
const RoomNotifs = require('../../../RoomNotifs'); import * as RoomNotifs from '../../../RoomNotifs';
const FormattingUtils = require('../../../utils/FormattingUtils'); import * as FormattingUtils from '../../../utils/FormattingUtils';
import AccessibleButton from '../elements/AccessibleButton'; import AccessibleButton from '../elements/AccessibleButton';
import ActiveRoomObserver from '../../../ActiveRoomObserver'; import ActiveRoomObserver from '../../../ActiveRoomObserver';
import RoomViewStore from '../../../stores/RoomViewStore'; import RoomViewStore from '../../../stores/RoomViewStore';
@ -72,16 +71,12 @@ module.exports = React.createClass({
}, },
_shouldShowMentionBadge: function() { _shouldShowMentionBadge: function() {
return this.state.notifState != RoomNotifs.MUTE; return this.state.notifState !== RoomNotifs.MUTE;
}, },
_isDirectMessageRoom: function(roomId) { _isDirectMessageRoom: function(roomId) {
const dmRooms = DMRoomMap.shared().getUserIdForRoomId(roomId); const dmRooms = DMRoomMap.shared().getUserIdForRoomId(roomId);
if (dmRooms) { return Boolean(dmRooms);
return true;
} else {
return false;
}
}, },
onRoomTimeline: function(ev, room) { onRoomTimeline: function(ev, room) {
@ -99,7 +94,7 @@ module.exports = React.createClass({
}, },
onAccountData: function(accountDataEvent) { onAccountData: function(accountDataEvent) {
if (accountDataEvent.getType() == 'm.push_rules') { if (accountDataEvent.getType() === 'm.push_rules') {
this.setState({ this.setState({
notifState: RoomNotifs.getRoomNotifsState(this.props.room.roomId), notifState: RoomNotifs.getRoomNotifsState(this.props.room.roomId),
}); });
@ -255,7 +250,7 @@ module.exports = React.createClass({
'mx_RoomTile_unread': this.props.unread, 'mx_RoomTile_unread': this.props.unread,
'mx_RoomTile_unreadNotify': notifBadges, 'mx_RoomTile_unreadNotify': notifBadges,
'mx_RoomTile_highlight': mentionBadges, 'mx_RoomTile_highlight': mentionBadges,
'mx_RoomTile_invited': (me && me.membership == 'invite'), 'mx_RoomTile_invited': (me && me.membership === 'invite'),
'mx_RoomTile_menuDisplayed': this.state.menuDisplayed, 'mx_RoomTile_menuDisplayed': this.state.menuDisplayed,
'mx_RoomTile_noBadges': !badges, 'mx_RoomTile_noBadges': !badges,
'mx_RoomTile_transparent': this.props.transparent, 'mx_RoomTile_transparent': this.props.transparent,
@ -273,7 +268,6 @@ module.exports = React.createClass({
let name = this.state.roomName; let name = this.state.roomName;
name = name.replace(":", ":\u200b"); // add a zero-width space to allow linewrapping after the colon name = name.replace(":", ":\u200b"); // add a zero-width space to allow linewrapping after the colon
let badge;
let badgeContent; let badgeContent;
if (this.state.badgeHover || this.state.menuDisplayed) { if (this.state.badgeHover || this.state.menuDisplayed) {
@ -285,7 +279,7 @@ module.exports = React.createClass({
badgeContent = '\u200B'; badgeContent = '\u200B';
} }
badge = <div className={badgeClasses} ref="badge" onClick={this.onBadgeClicked}>{ badgeContent }</div>; const badge = <div className={badgeClasses} ref="badge" onClick={this.onBadgeClicked}>{ badgeContent }</div>;
const EmojiText = sdk.getComponent('elements.EmojiText'); const EmojiText = sdk.getComponent('elements.EmojiText');
let label; let label;
@ -317,9 +311,9 @@ module.exports = React.createClass({
const RoomAvatar = sdk.getComponent('avatars.RoomAvatar'); const RoomAvatar = sdk.getComponent('avatars.RoomAvatar');
let directMessageIndicator; let dmIndicator;
if (this._isDirectMessageRoom(this.props.room.roomId)) { if (this._isDirectMessageRoom(this.props.room.roomId)) {
directMessageIndicator = <img src="img/icon_person.svg" className="mx_RoomTile_dm" width="11" height="13" alt="dm" />; dmIndicator = <img src="img/icon_person.svg" className="mx_RoomTile_dm" width="11" height="13" alt="dm" />;
} }
return <AccessibleButton tabIndex="0" return <AccessibleButton tabIndex="0"
@ -332,7 +326,7 @@ module.exports = React.createClass({
<div className={avatarClasses}> <div className={avatarClasses}>
<div className="mx_RoomTile_avatar_container"> <div className="mx_RoomTile_avatar_container">
<RoomAvatar room={this.props.room} width={24} height={24} /> <RoomAvatar room={this.props.room} width={24} height={24} />
{ directMessageIndicator } { dmIndicator }
</div> </div>
</div> </div>
<div className="mx_RoomTile_nameContainer"> <div className="mx_RoomTile_nameContainer">