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 {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)
}
};
}

View file

@ -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));
}