From d6233e7c77eb9b47b22e5cf0dd312d7baffa7c2d Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Tue, 7 Dec 2021 16:28:53 +0530 Subject: [PATCH] Render static avatar --- src/domain/session/room/timeline/tiles/BaseTextTile.js | 8 ++++---- .../web/ui/session/room/timeline/TextMessageView.js | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/domain/session/room/timeline/tiles/BaseTextTile.js b/src/domain/session/room/timeline/tiles/BaseTextTile.js index 0da6cd40..7c0aa7b0 100644 --- a/src/domain/session/room/timeline/tiles/BaseTextTile.js +++ b/src/domain/session/room/timeline/tiles/BaseTextTile.js @@ -17,7 +17,7 @@ limitations under the License. import {BaseMessageTile} from "./BaseMessageTile.js"; import {stringAsBody} from "../MessageBody.js"; import {createEnum} from "../../../../../utils/enum"; -import {avatarInitials, getIdentifierColorNumber} from "../../../../avatar.js"; +import {avatarInitials, getAvatarHttpUrl, getIdentifierColorNumber} from "../../../../avatar.js"; export const BodyFormat = createEnum("Plain", "Html"); @@ -70,9 +70,9 @@ export class BaseTextTile extends BaseMessageTile { body: this._parseBody(body, format), sender: entry.displayName, avatar: { - colorNumber: getIdentifierColorNumber(entry.sender), - initial: avatarInitials(entry.displayName), - avatarUrl: entry.avatarUrl + avatarColorNumber: getIdentifierColorNumber(entry.sender), + avatarLetter: avatarInitials(entry.displayName), + avatarUrl: (size) => getAvatarHttpUrl(entry.avatarUrl, size, this.platform, this._mediaRepository) } }; } diff --git a/src/platform/web/ui/session/room/timeline/TextMessageView.js b/src/platform/web/ui/session/room/timeline/TextMessageView.js index 2f8d10a7..a70aaba2 100644 --- a/src/platform/web/ui/session/room/timeline/TextMessageView.js +++ b/src/platform/web/ui/session/room/timeline/TextMessageView.js @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { renderStaticAvatar } from "../../../avatar"; import {tag, text} from "../../../general/html"; import {BaseMessageView} from "./BaseMessageView.js"; @@ -39,9 +40,9 @@ export class TextMessageView extends BaseMessageView { if (!body) { return; } - const replyContainer = t.blockquote([ - t.a({ className: "link", href: "#" }, "In reply to"), - t.a({ className: "pill", href: "#" }, [tag.div({class: `avatar size-12 usercolor${avatar.colorNumber}`}, text(avatar.initial)), sender]), t.br()]); + const replyContainer = tag.blockquote([ + tag.a({ className: "link", href: "#" }, "In reply to"), + tag.a({ className: "pill", href: "#" }, [renderStaticAvatar(avatar, 12), sender]), tag.br()]); for (const part of body.parts) { replyContainer.appendChild(renderPart(part)); }