Do room avatars properly.

pull/258/head
David Baker 2015-10-22 13:10:02 +01:00
parent 4b645bcd66
commit 08270b26ee
4 changed files with 18 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

View File

@ -17,6 +17,7 @@ limitations under the License.
'use strict'; 'use strict';
var React = require('react'); var React = require('react');
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var RoomAvatarController = require('matrix-react-sdk/lib/controllers/atoms/RoomAvatar') var RoomAvatarController = require('matrix-react-sdk/lib/controllers/atoms/RoomAvatar')
@ -24,6 +25,23 @@ module.exports = React.createClass({
displayName: 'RoomAvatar', displayName: 'RoomAvatar',
mixins: [RoomAvatarController], mixins: [RoomAvatarController],
getUrlList: function() {
return [
this.roomAvatarUrl(),
this.getOneToOneAvatar(),
this.getFallbackAvatar()
];
},
getFallbackAvatar: function() {
var images = [ '80cef4', '50e2c2', 'f4c371' ];
var total = 0;
for (var i = 0; i < this.props.room.roomId.length; ++i) {
total += this.props.room.roomId.charCodeAt(i);
}
return 'img/' + images[total % images.length] + '.png';
},
render: function() { render: function() {
return ( return (
<img className="mx_RoomAvatar" src={this.state.imageUrl} onError={this.onError} <img className="mx_RoomAvatar" src={this.state.imageUrl} onError={this.onError}