From 7b5796ce0340a616d2183de2ead0dcab5e8e3a0e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 4 Dec 2020 18:50:07 +0100 Subject: [PATCH] always show default avatar if none available --- src/preview/PreviewViewModel.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/preview/PreviewViewModel.js b/src/preview/PreviewViewModel.js index d025782..5c340eb 100644 --- a/src/preview/PreviewViewModel.js +++ b/src/preview/PreviewViewModel.js @@ -20,6 +20,8 @@ import {resolveServer} from "./HomeServer.js"; import {ClientListViewModel} from "../open/ClientListViewModel.js"; import {ClientViewModel} from "../open/ClientViewModel.js"; +const DEFAULT_AVATAR = "images/chat-icon.svg"; + export class PreviewViewModel extends ViewModel { constructor(options) { super(options); @@ -82,7 +84,7 @@ export class PreviewViewModel extends ViewModel { this.name = profile.displayname || userId; this.avatarUrl = profile.avatar_url ? homeserver.mxcUrlThumbnail(profile.avatar_url, 64, 64, "crop") : - null; + DEFAULT_AVATAR; this.identifier = userId; } @@ -99,7 +101,7 @@ export class PreviewViewModel extends ViewModel { this.name = publicRoom?.name || publicRoom?.canonical_alias || link.identifier; this.avatarUrl = publicRoom?.avatar_url ? homeserver.mxcUrlThumbnail(publicRoom.avatar_url, 64, 64, "crop") : - null; + DEFAULT_AVATAR; this.memberCount = publicRoom?.num_joined_members; this.topic = publicRoom?.topic; this.identifier = publicRoom?.canonical_alias || link.identifier; @@ -111,6 +113,6 @@ export class PreviewViewModel extends ViewModel { _setNoPreview(link) { this.name = link.identifier; this.identifier = null; - this.avatarUrl = "images/chat-icon.svg"; + this.avatarUrl = DEFAULT_AVATAR; } }