diff --git a/src/components/views/avatars/BaseAvatar.tsx b/src/components/views/avatars/BaseAvatar.tsx index 8ce05e0a55..e0d0edd279 100644 --- a/src/components/views/avatars/BaseAvatar.tsx +++ b/src/components/views/avatars/BaseAvatar.tsx @@ -44,7 +44,7 @@ interface IProps { className?: string; } -const calculateUrls = (url, urls) => { +const calculateUrls = (url: string, urls: string[]) => { // work out the full set of urls to try to load. This is formed like so: // imageUrls: [ props.url, ...props.urls ] diff --git a/src/components/views/avatars/DecoratedRoomAvatar.tsx b/src/components/views/avatars/DecoratedRoomAvatar.tsx index f15538eabf..bd67255fc2 100644 --- a/src/components/views/avatars/DecoratedRoomAvatar.tsx +++ b/src/components/views/avatars/DecoratedRoomAvatar.tsx @@ -201,8 +201,8 @@ export default class DecoratedRoomAvatar extends React.PureComponent - {icon} - {badge} + { icon } + { badge } ; } } diff --git a/src/utils/exportUtils/HtmlExport.tsx b/src/utils/exportUtils/HtmlExport.tsx index dfdd8a32cd..f124359882 100644 --- a/src/utils/exportUtils/HtmlExport.tsx +++ b/src/utils/exportUtils/HtmlExport.tsx @@ -6,16 +6,18 @@ import { mediaFromContent } from "../../customisations/Media"; import { Room } from "matrix-js-sdk/src/models/room"; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { Exporter } from "./Exporter"; -import * as ponyfill from "web-streams-polyfill/ponyfill" import { renderToStaticMarkup } from 'react-dom/server' import { Layout } from "../../settings/Layout"; import { shouldFormContinuation } from "../../components/structures/MessagePanel"; import { wantsDateSeparator } from "../../DateUtils"; import { RoomPermalinkCreator } from "../permalinks/Permalinks"; +import * as ponyfill from "web-streams-polyfill/ponyfill" +import * as Avatar from "../../Avatar"; import EventTile, { haveTileForEvent } from "../../components/views/rooms/EventTile"; import DateSeparator from "../../components/views/messages/DateSeparator"; import exportCSS from "./exportCSS"; import exportJS from "./exportJS"; +import BaseAvatar from "../../components/views/avatars/BaseAvatar"; export default class HTMLExporter extends Exporter { protected zip: JSZip; @@ -29,7 +31,29 @@ export default class HTMLExporter extends Exporter { this.permalinkCreator = new RoomPermalinkCreator(this.room); } - protected wrapHTML(content: string, room: Room) { + protected async getRoomAvatar() { + let blob: Blob; + const avatarUrl = Avatar.avatarUrlForRoom(this.room, 32, 32, "crop"); + if (avatarUrl) { + const image = await fetch(avatarUrl); + blob = await image.blob(); + this.zip.file("room.png", blob); + } + const avatar = ( + + ); + return renderToStaticMarkup(avatar); + } + + protected async wrapHTML(content: string, room: Room) { + const roomAvatar = await this.getRoomAvatar(); return ` @@ -54,22 +78,7 @@ export default class HTMLExporter extends Exporter {
- + ${roomAvatar}
@@ -228,7 +237,7 @@ export default class HTMLExporter extends Exporter { content += body; prevEvent = event; } - return this.wrapHTML(content, room); + return await this.wrapHTML(content, room); } public async export() {