diff --git a/src/TextForEvent.tsx b/src/TextForEvent.tsx index 5ab1ceb9f4..7845091c48 100644 --- a/src/TextForEvent.tsx +++ b/src/TextForEvent.tsx @@ -167,7 +167,7 @@ function textForTopicEvent(ev: MatrixEvent): () => string | null { } function textForRoomAvatarEvent(ev: MatrixEvent): () => string | null { - const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(); + const senderDisplayName = ev?.sender?.name || ev.getSender(); return () => _t('%(senderDisplayName)s changed the room avatar.', { senderDisplayName }); } @@ -298,11 +298,12 @@ function textForMessageEvent(ev: MatrixEvent): () => string | null { if (ev.isRedacted()) { message = _t("Message deleted"); const unsigned = ev.getUnsigned(); - const redactedBecauseUserId = unsigned && unsigned.redacted_because && unsigned.redacted_because.sender; + const redactedBecauseUserId = unsigned?.redacted_because?.sender; if (redactedBecauseUserId && redactedBecauseUserId !== ev.getSender()) { const room = MatrixClientPeg.get().getRoom(ev.getRoomId()); - const sender = room && room.getMember(redactedBecauseUserId); - message = _t("Message deleted by %(name)s", { name: sender ? sender.name : redactedBecauseUserId }); + const sender = room?.getMember(redactedBecauseUserId); + message = _t("Message deleted by %(name)s", { name: sender?.name + || redactedBecauseUserId }); } } if (ev.getContent().msgtype === "m.emote") { diff --git a/src/components/views/messages/MImageBody.tsx b/src/components/views/messages/MImageBody.tsx index 4fa1161d82..ae82c57a5e 100644 --- a/src/components/views/messages/MImageBody.tsx +++ b/src/components/views/messages/MImageBody.tsx @@ -428,7 +428,7 @@ export default class MImageBody extends React.Component { // Overidden by MStickerBody protected wrapImage(contentUrl: string, children: JSX.Element): JSX.Element { - return + return { children } ; } diff --git a/src/utils/exportUtils/Exporter.ts b/src/utils/exportUtils/Exporter.ts index 920d690174..8c419ce657 100644 --- a/src/utils/exportUtils/Exporter.ts +++ b/src/utils/exportUtils/Exporter.ts @@ -32,9 +32,9 @@ type BlobFile = { }; export default abstract class Exporter { - protected files: BlobFile[]; + protected files: BlobFile[] = []; protected client: MatrixClient; - protected cancelled: boolean; + protected cancelled = false; protected constructor( protected room: Room, @@ -48,8 +48,6 @@ export default abstract class Exporter { ) { throw new Error("Invalid export options"); } - this.cancelled = false; - this.files = []; this.client = MatrixClientPeg.get(); window.addEventListener("beforeunload", this.onBeforeUnload); } @@ -72,7 +70,7 @@ export default abstract class Exporter { this.files.push(file); } - protected async downloadZIP(): Promise { + protected async downloadZIP(): Promise { const filename = `matrix-export-${formatFullDateNoDay(new Date())}.zip`; const zip = new JSZip(); @@ -258,5 +256,5 @@ export default abstract class Exporter { return mxEv.getType() === attachmentTypes[0] || attachmentTypes.includes(mxEv.getContent().msgtype); } - abstract export(): Promise; + abstract export(): Promise; }