have individual getters for kickDetails

This commit is contained in:
Bruno Windels 2021-05-11 13:07:31 +02:00
parent 00d4dc9518
commit 6bb9140720

View file

@ -21,6 +21,10 @@ import {RoomMember} from "./members/RoomMember.js";
export class ArchivedRoom extends BaseRoom { export class ArchivedRoom extends BaseRoom {
constructor(options) { constructor(options) {
super(options); super(options);
/**
Some details from our own member event when being kicked or banned.
We can't get this from the member store, because we don't store the reason field there.
*/
this._kickDetails = null; this._kickDetails = null;
this._kickedBy = null; this._kickedBy = null;
} }
@ -87,15 +91,24 @@ export class ArchivedRoom extends BaseRoom {
this._emitUpdate(); this._emitUpdate();
} }
getLeaveDetails() { get isKicked() {
if (this.membership === "leave") { return this._kickDetails?.membership === "leave";
return { }
isKicked: this._kickDetails?.membership === "leave",
isBanned: this._kickDetails?.membership === "ban", get isBanned() {
reason: this._kickDetails?.reason, return this._kickDetails?.membership === "ban";
sender: this._kickAuthor, }
};
} get kickedBy() {
return this._kickedBy;
}
get kickReason() {
return this._kickDetails?.reason;
}
isArchived() {
return true;
} }
forget() { forget() {