1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2026-01-03 23:22:30 +03:00

Add option to prevent the SDK from returning default avatar URLs.

This commit is contained in:
David Baker
2015-08-13 17:07:34 +01:00
parent deaaee4986
commit 9fab329a70

View File

@@ -1393,17 +1393,21 @@ MatrixClient.prototype.setAvatarUrl = function(url, callback) {
* @param {Number} height The desired height of the thumbnail.
* @param {string} resizeMethod The thumbnail resize method to use, either
* "crop" or "scale".
* @param {Boolean} allowDefault (optional) Passing false causes this method to
* return null if the user has no avatar image. Otherwise, a default image URL
* will be returned.
* @return {?string} the avatar URL or null.
*/
MatrixClient.prototype.getAvatarUrlForMember =
function(member, width, height, resizeMethod) {
function(member, width, height, resizeMethod, allowDefault) {
if (!member || !member.events.member) {
return null;
}
if (allowDefault === undefined) { allowDefault = true; }
var rawUrl = member.events.member.getContent().avatar_url;
if (rawUrl) {
return this._http.getHttpUriForMxc(rawUrl, width, height, resizeMethod);
} else {
} else if (allowDefault) {
return this._http.getIdenticonUri(member.userId, width, height);
}
return null;