From 83b233b97e0e029efca91212b7a52d3a1b2df592 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Wed, 29 Jun 2022 15:58:51 +0530 Subject: [PATCH] Add type for invite rom --- src/matrix/room/BaseRoom.js | 2 +- src/matrix/room/Invite.js | 8 ++++++-- src/matrix/room/timeline/persistence/GapWriter.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index 7865723b..76c6c9f7 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -415,7 +415,7 @@ export class BaseRoom extends EventEmitter { } get type() { - return this._summary.data.type; + return this._summary.data.type ?? undefined; } get lastMessageTimestamp() { diff --git a/src/matrix/room/Invite.js b/src/matrix/room/Invite.js index 6c5ef121..4324ba38 100644 --- a/src/matrix/room/Invite.js +++ b/src/matrix/room/Invite.js @@ -61,6 +61,10 @@ export class Invite extends EventEmitter { return this._inviteData.avatarColorId || this.id; } + get type() { + return this._inviteData.type ?? undefined; + } + get timestamp() { return this._inviteData.timestamp; } @@ -89,7 +93,7 @@ export class Invite extends EventEmitter { await this._platform.logger.wrapOrRun(log, "acceptInvite", async log => { this._accepting = true; this._emitChange("accepting"); - await this._hsApi.join(this._roomId, {log}).response(); + await this._hsApi.joinIdOrAlias(this.canonicalAlias ?? this._roomId, {log}).response(); }); } @@ -189,7 +193,7 @@ export class Invite extends EventEmitter { roomId: this.id, isEncrypted: !!summaryData.encryption, isDirectMessage: summaryData.isDirectMessage, -// type: + type: summaryData.type, name, avatarUrl, avatarColorId, diff --git a/src/matrix/room/timeline/persistence/GapWriter.js b/src/matrix/room/timeline/persistence/GapWriter.js index 3e520608..4458e1c5 100644 --- a/src/matrix/room/timeline/persistence/GapWriter.js +++ b/src/matrix/room/timeline/persistence/GapWriter.js @@ -163,7 +163,7 @@ export class GapWriter { if (!Array.isArray(chunk)) { throw new Error("Invalid chunk in response"); } - if (typeof end !== "string") { + if (typeof end !== "string" && typeof end !== "undefined") { throw new Error("Invalid end token in response"); }