From 08270b26ee6df015cde22b3b271f032c7870774a Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 22 Oct 2015 13:10:02 +0100 Subject: [PATCH] Do room avatars properly. --- src/skins/vector/img/50e2c2.png | Bin 0 -> 146 bytes src/skins/vector/img/80cef4.png | Bin 0 -> 146 bytes src/skins/vector/img/f4c371.png | Bin 0 -> 146 bytes src/skins/vector/views/atoms/RoomAvatar.js | 18 ++++++++++++++++++ 4 files changed, 18 insertions(+) create mode 100644 src/skins/vector/img/50e2c2.png create mode 100644 src/skins/vector/img/80cef4.png create mode 100644 src/skins/vector/img/f4c371.png diff --git a/src/skins/vector/img/50e2c2.png b/src/skins/vector/img/50e2c2.png new file mode 100644 index 0000000000000000000000000000000000000000..ee0f85589570374f5e1dec95ff7867a6c731f7bf GIT binary patch literal 146 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1SFZ~=vx6P$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SFl*+=BsWw1GCY~;iAr-gYoMq%?FyLTNsC6=qKC0CJ@Yw=}$jcia9u?Xc lp(ECPGzm(5Joz;H@|siKCz>m5)(gQu&X%Q~loCII5dEd>Ao literal 0 HcmV?d00001 diff --git a/src/skins/vector/views/atoms/RoomAvatar.js b/src/skins/vector/views/atoms/RoomAvatar.js index ec2bf5ec2..39b995a7a 100644 --- a/src/skins/vector/views/atoms/RoomAvatar.js +++ b/src/skins/vector/views/atoms/RoomAvatar.js @@ -17,6 +17,7 @@ limitations under the License. 'use strict'; var React = require('react'); +var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); var RoomAvatarController = require('matrix-react-sdk/lib/controllers/atoms/RoomAvatar') @@ -24,6 +25,23 @@ module.exports = React.createClass({ displayName: 'RoomAvatar', 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() { return (