File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed
Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -17,13 +17,31 @@ limitations under the License.
1717'use strict' ;
1818
1919var React = require ( 'react' ) ;
20+ var MatrixClientPeg = require ( 'matrix-react-sdk/lib/MatrixClientPeg' ) ;
2021
2122var RoomAvatarController = require ( 'matrix-react-sdk/lib/controllers/atoms/RoomAvatar' )
2223
2324module . 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 }
You can’t perform that action at this time.
0 commit comments