Update for new default avatar API.

This commit is contained in:
David Baker 2015-09-28 17:06:39 +01:00
parent c3f32b74e4
commit 7d540572fd
2 changed files with 15 additions and 10 deletions

View File

@ -19,16 +19,6 @@ limitations under the License.
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
module.exports = { module.exports = {
avatarUrlForMember: function(member, width, height, resizeMethod) {
var url = MatrixClientPeg.get().getAvatarUrlForMember(
member, width, height, resizeMethod, false
);
if (url === null) {
url = this.defaultAvatarUrlForString(member.userId);
}
return url;
},
defaultAvatarUrlForString: function(s) { defaultAvatarUrlForString: function(s) {
var total = 0; var total = 0;
for (var i = 0; i < s.length; ++i) { for (var i = 0; i < s.length; ++i) {

View File

@ -17,6 +17,7 @@ limitations under the License.
'use strict'; 'use strict';
var React = require('react'); var React = require('react');
var Avatar = require('../../../../Avatar');
var MemberAvatarController = require('matrix-react-sdk/lib/controllers/atoms/MemberAvatar') var MemberAvatarController = require('matrix-react-sdk/lib/controllers/atoms/MemberAvatar')
@ -24,6 +25,20 @@ module.exports = React.createClass({
displayName: 'MemberAvatar', displayName: 'MemberAvatar',
mixins: [MemberAvatarController], mixins: [MemberAvatarController],
avatarUrlForMember: function(member) {
return Avatar.avatarUrlForMember(
member,
this.props.member,
this.props.width,
this.props.height,
this.props.resizeMethod
);
},
skinnedDefaultAvatarUrl: function(member, width, height, resizeMethod) {
return Avatar.defaultAvatarUrlForString(member.userId);
},
render: function() { render: function() {
return ( return (
<img className="mx_MemberAvatar" src={this.state.imageUrl} <img className="mx_MemberAvatar" src={this.state.imageUrl}