diff --git a/src/lib.ts b/src/lib.ts index 854248c2..6e93be14 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -21,6 +21,7 @@ export {ConsoleReporter} from "./logging/ConsoleReporter"; export {Platform} from "./platform/web/Platform.js"; export {Client, LoadStatus} from "./matrix/Client.js"; export {RoomStatus} from "./matrix/room/common"; +export {AttachmentUpload} from "./matrix/room/AttachmentUpload"; export {CallIntent} from "./matrix/calls/callEventTypes"; // export everything needed to observe state events on all rooms using session.observeRoomState export type {RoomStateHandler} from "./matrix/room/state/types"; diff --git a/src/matrix/room/BaseRoom.js b/src/matrix/room/BaseRoom.js index b8f172d0..7865723b 100644 --- a/src/matrix/room/BaseRoom.js +++ b/src/matrix/room/BaseRoom.js @@ -73,6 +73,11 @@ export class BaseRoom extends EventEmitter { return value; } + async getStateEvent(type, key = '') { + const txn = await this._storage.readTxn(['roomState']); + return txn.roomState.get(this.id, type, key); + } + async _addStateObserver(stateObserver, txn) { if (!txn) { txn = await this._storage.readTxn([this._storage.storeNames.roomState]); @@ -409,6 +414,10 @@ export class BaseRoom extends EventEmitter { return this._roomId; } + get type() { + return this._summary.data.type; + } + get lastMessageTimestamp() { return this._summary.data.lastMessageTimestamp; } @@ -446,6 +455,10 @@ export class BaseRoom extends EventEmitter { return this._summary.data.membership; } + get isDirectMessage() { + return this._summary.data.isDirectMessage; + } + isDirectMessageForUserId(userId) { if (this._summary.data.dmUserId === userId) { return true; diff --git a/src/matrix/room/RoomSummary.js b/src/matrix/room/RoomSummary.js index 62608683..c9114594 100644 --- a/src/matrix/room/RoomSummary.js +++ b/src/matrix/room/RoomSummary.js @@ -82,6 +82,7 @@ export function processStateEvent(data, event, ownUserId) { if (event.type === "m.room.create") { data = data.cloneIfNeeded(); data.lastMessageTimestamp = event.origin_server_ts; + data.type = event.content?.type ?? null; } else if (event.type === "m.room.encryption") { const algorithm = event.content?.algorithm; if (!data.encryption && algorithm === MEGOLM_ALGORITHM) { @@ -167,6 +168,7 @@ export class SummaryData { constructor(copy, roomId) { this.roomId = copy ? copy.roomId : roomId; this.name = copy ? copy.name : null; + this.type = copy ? copy.type : null; this.lastMessageTimestamp = copy ? copy.lastMessageTimestamp : null; this.isUnread = copy ? copy.isUnread : false; this.encryption = copy ? copy.encryption : null;