Skip to content

Commit 08270b2

Browse files
committed
Do room avatars properly.
1 parent 4b645bc commit 08270b2

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

src/skins/vector/img/50e2c2.png

146 Bytes
Loading

src/skins/vector/img/80cef4.png

146 Bytes
Loading

src/skins/vector/img/f4c371.png

146 Bytes
Loading

src/skins/vector/views/atoms/RoomAvatar.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,31 @@ limitations under the License.
1717
'use strict';
1818

1919
var React = require('react');
20+
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
2021

2122
var RoomAvatarController = require('matrix-react-sdk/lib/controllers/atoms/RoomAvatar')
2223

2324
module.exports = React.createClass({
2425
displayName: 'RoomAvatar',
2526
mixins: [RoomAvatarController],
2627

28+
getUrlList: function() {
29+
return [
30+
this.roomAvatarUrl(),
31+
this.getOneToOneAvatar(),
32+
this.getFallbackAvatar()
33+
];
34+
},
35+
36+
getFallbackAvatar: function() {
37+
var images = [ '80cef4', '50e2c2', 'f4c371' ];
38+
var total = 0;
39+
for (var i = 0; i < this.props.room.roomId.length; ++i) {
40+
total += this.props.room.roomId.charCodeAt(i);
41+
}
42+
return 'img/' + images[total % images.length] + '.png';
43+
},
44+
2745
render: function() {
2846
return (
2947
<img className="mx_RoomAvatar" src={this.state.imageUrl} onError={this.onError}

0 commit comments

Comments
 (0)