File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,3 +19,8 @@ limitations under the License.
1919 border-radius : 20px ;
2020}
2121
22+ . mx_MemberAvatar_initial {
23+ position : absolute;
24+ color : # fff;
25+ text-align : center;
26+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2015 OpenMarket Ltd
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ . mx_RoomAvatar {
18+ }
19+
20+ . mx_RoomAvatar_initial {
21+ position : absolute;
22+ color : # fff;
23+ text-align : center;
24+ }
Original file line number Diff line number Diff line change @@ -40,6 +40,25 @@ module.exports = React.createClass({
4040 } ,
4141
4242 render : function ( ) {
43+ // XXX: recalculates default avatar url constantly
44+ if ( this . state . imageUrl === this . defaultAvatarUrl ( this . props . member ) ) {
45+ var initial ;
46+ if ( this . props . member . name [ 0 ] )
47+ initial = this . props . member . name [ 0 ] . toUpperCase ( ) ;
48+ if ( initial === '@' && this . props . member . name [ 1 ] )
49+ initial = this . props . member . name [ 1 ] . toUpperCase ( ) ;
50+
51+ return (
52+ < span >
53+ < span className = "mx_MemberAvatar_initial"
54+ style = { { fontSize : ( this . props . width * 0.75 ) + "px" ,
55+ width : this . props . width + "px" ,
56+ lineHeight : this . props . height * 1.2 + "px" } } > { initial } </ span >
57+ < img className = "mx_MemberAvatar" src = { this . state . imageUrl }
58+ onError = { this . onError } width = { this . props . width } height = { this . props . height } />
59+ </ span >
60+ ) ;
61+ }
4362 return (
4463 < img className = "mx_MemberAvatar" src = { this . state . imageUrl }
4564 onError = { this . onError }
Original file line number Diff line number Diff line change @@ -43,13 +43,33 @@ module.exports = React.createClass({
4343
4444 render : function ( ) {
4545 var style = {
46- maxWidth : this . props . width ,
47- maxHeight : this . props . height ,
46+ width : this . props . width ,
47+ height : this . props . height ,
4848 } ;
49- return (
50- < img className = "mx_RoomAvatar" src = { this . state . imageUrl } onError = { this . onError }
51- style = { style }
52- />
53- ) ;
49+
50+ // XXX: recalculates fallback avatar constantly
51+ if ( this . state . imageUrl === this . getFallbackAvatar ( ) ) {
52+ var initial ;
53+ if ( this . props . room . name [ 0 ] )
54+ initial = this . props . room . name [ 0 ] . toUpperCase ( ) ;
55+ if ( initial === '@' && this . props . room . name [ 1 ] )
56+ initial = this . props . room . name [ 1 ] . toUpperCase ( ) ;
57+
58+ return (
59+ < span >
60+ < span className = "mx_RoomAvatar_initial"
61+ style = { { fontSize : ( this . props . width * 0.75 ) + "px" ,
62+ width : this . props . width + "px" ,
63+ lineHeight : this . props . height * 1.2 + "px" } } > { initial } </ span >
64+ < img className = "mx_RoomAvatar" src = { this . state . imageUrl }
65+ onError = { this . onError } style = { style } />
66+ </ span >
67+ ) ;
68+ }
69+ else {
70+ return < img className = "mx_RoomAvatar" src = { this . state . imageUrl }
71+ onError = { this . onError } style = { style } />
72+ }
73+
5474 }
5575} ) ;
You can’t perform that action at this time.
0 commit comments