diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index bd1c8cc972..297d615d30 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -179,20 +179,26 @@ const FeaturedRoom = React.createClass({ render: function() { const RoomAvatar = sdk.getComponent("avatars.RoomAvatar"); + const roomName = this.props.summaryInfo.profile.name || + this.props.summaryInfo.profile.canonical_alias || + _t("Unnamed Room"); + const oobData = { roomId: this.props.summaryInfo.room_id, avatarUrl: this.props.summaryInfo.profile.avatar_url, - name: this.props.summaryInfo.profile.name, + name: roomName, }; + let permalink = null; if (this.props.summaryInfo.profile && this.props.summaryInfo.profile.canonical_alias) { permalink = 'https://matrix.to/#/' + this.props.summaryInfo.profile.canonical_alias; } + let roomNameNode = null; if (permalink) { - roomNameNode = {this.props.summaryInfo.profile.name}; + roomNameNode = {roomName}; } else { - roomNameNode = {this.props.summaryInfo.profile.name}; + roomNameNode = {roomName}; } const deleteButton = this.props.editing ? diff --git a/src/components/views/avatars/RoomAvatar.js b/src/components/views/avatars/RoomAvatar.js index a18a52b3c0..11554b2379 100644 --- a/src/components/views/avatars/RoomAvatar.js +++ b/src/components/views/avatars/RoomAvatar.js @@ -13,11 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -var React = require('react'); -var ContentRepo = require("matrix-js-sdk").ContentRepo; -var MatrixClientPeg = require('../../../MatrixClientPeg'); -var Avatar = require('../../../Avatar'); -var sdk = require("../../../index"); +import React from "react"; +import {ContentRepo} from "matrix-js-sdk"; +import MatrixClientPeg from "../../../MatrixClientPeg"; +import sdk from "../../../index"; module.exports = React.createClass({ displayName: 'RoomAvatar', @@ -30,7 +29,7 @@ module.exports = React.createClass({ oobData: React.PropTypes.object, width: React.PropTypes.number, height: React.PropTypes.number, - resizeMethod: React.PropTypes.string + resizeMethod: React.PropTypes.string, }, getDefaultProps: function() { @@ -44,13 +43,13 @@ module.exports = React.createClass({ getInitialState: function() { return { - urls: this.getImageUrls(this.props) + urls: this.getImageUrls(this.props), }; }, componentWillReceiveProps: function(newProps) { this.setState({ - urls: this.getImageUrls(newProps) + urls: this.getImageUrls(newProps), }); }, @@ -61,11 +60,10 @@ module.exports = React.createClass({ props.oobData.avatarUrl, Math.floor(props.width * window.devicePixelRatio), Math.floor(props.height * window.devicePixelRatio), - props.resizeMethod + props.resizeMethod, ), // highest priority this.getRoomAvatarUrl(props), - this.getOneToOneAvatar(props), - this.getFallbackAvatar(props) // lowest priority + this.getOneToOneAvatar(props), // lowest priority ].filter(function(url) { return (url != null && url != ""); }); @@ -79,17 +77,17 @@ module.exports = React.createClass({ Math.floor(props.width * window.devicePixelRatio), Math.floor(props.height * window.devicePixelRatio), props.resizeMethod, - false + false, ); }, getOneToOneAvatar: function(props) { if (!props.room) return null; - var mlist = props.room.currentState.members; - var userIds = []; + const mlist = props.room.currentState.members; + const userIds = []; // for .. in optimisation to return early if there are >2 keys - for (var uid in mlist) { + for (const uid in mlist) { if (mlist.hasOwnProperty(uid)) { userIds.push(uid); } @@ -99,7 +97,7 @@ module.exports = React.createClass({ } if (userIds.length == 2) { - var theOtherGuy = null; + let theOtherGuy = null; if (mlist[userIds[0]].userId == MatrixClientPeg.get().credentials.userId) { theOtherGuy = mlist[userIds[1]]; } else { @@ -110,7 +108,7 @@ module.exports = React.createClass({ Math.floor(props.width * window.devicePixelRatio), Math.floor(props.height * window.devicePixelRatio), props.resizeMethod, - false + false, ); } else if (userIds.length == 1) { return mlist[userIds[0]].getAvatarUrl( @@ -118,37 +116,24 @@ module.exports = React.createClass({ Math.floor(props.width * window.devicePixelRatio), Math.floor(props.height * window.devicePixelRatio), props.resizeMethod, - false + false, ); } else { return null; } }, - getFallbackAvatar: function(props) { - let roomId = null; - if (props.oobData && props.oobData.roomId) { - roomId = this.props.oobData.roomId; - } else if (props.room) { - roomId = props.room.roomId; - } else { - return null; - } - - return Avatar.defaultAvatarUrlForString(roomId); - }, - render: function() { - var BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); + const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); - var {room, oobData, ...otherProps} = this.props; + const {room, oobData, ...otherProps} = this.props; - var roomName = room ? room.name : oobData.name; + const roomName = room ? room.name : oobData.name; return ( ); - } + }, });