forked from mystiq/hydrogen-web
Merge pull request #737 from vector-im/add-room-type-in-summary
Add room type in summary
This commit is contained in:
commit
28c699939e
3 changed files with 16 additions and 0 deletions
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue