Render static avatar

This commit is contained in:
RMidhunSuresh 2021-12-07 16:28:53 +05:30
parent 540aa6c546
commit d6233e7c77
2 changed files with 8 additions and 7 deletions

View file

@ -17,7 +17,7 @@ limitations under the License.
import {BaseMessageTile} from "./BaseMessageTile.js"; import {BaseMessageTile} from "./BaseMessageTile.js";
import {stringAsBody} from "../MessageBody.js"; import {stringAsBody} from "../MessageBody.js";
import {createEnum} from "../../../../../utils/enum"; import {createEnum} from "../../../../../utils/enum";
import {avatarInitials, getIdentifierColorNumber} from "../../../../avatar.js"; import {avatarInitials, getAvatarHttpUrl, getIdentifierColorNumber} from "../../../../avatar.js";
export const BodyFormat = createEnum("Plain", "Html"); export const BodyFormat = createEnum("Plain", "Html");
@ -70,9 +70,9 @@ export class BaseTextTile extends BaseMessageTile {
body: this._parseBody(body, format), body: this._parseBody(body, format),
sender: entry.displayName, sender: entry.displayName,
avatar: { avatar: {
colorNumber: getIdentifierColorNumber(entry.sender), avatarColorNumber: getIdentifierColorNumber(entry.sender),
initial: avatarInitials(entry.displayName), avatarLetter: avatarInitials(entry.displayName),
avatarUrl: entry.avatarUrl avatarUrl: (size) => getAvatarHttpUrl(entry.avatarUrl, size, this.platform, this._mediaRepository)
} }
}; };
} }

View file

@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { renderStaticAvatar } from "../../../avatar";
import {tag, text} from "../../../general/html"; import {tag, text} from "../../../general/html";
import {BaseMessageView} from "./BaseMessageView.js"; import {BaseMessageView} from "./BaseMessageView.js";
@ -39,9 +40,9 @@ export class TextMessageView extends BaseMessageView {
if (!body) { if (!body) {
return; return;
} }
const replyContainer = t.blockquote([ const replyContainer = tag.blockquote([
t.a({ className: "link", href: "#" }, "In reply to"), tag.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()]); tag.a({ className: "pill", href: "#" }, [renderStaticAvatar(avatar, 12), sender]), tag.br()]);
for (const part of body.parts) { for (const part of body.parts) {
replyContainer.appendChild(renderPart(part)); replyContainer.appendChild(renderPart(part));
} }