From 1a8427925c30c62ac29fc867ce4fa64dc3f6f258 Mon Sep 17 00:00:00 2001 From: Bad Date: Mon, 26 Oct 2020 22:55:27 +0100 Subject: [PATCH] Add unknown memberships --- src/js/events/membership.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/js/events/membership.js b/src/js/events/membership.js index 97daea3..9b554cf 100644 --- a/src/js/events/membership.js +++ b/src/js/events/membership.js @@ -1,10 +1,10 @@ const {Event} = require("./event") -function createMembershipEvent(membership, text) { +function createMembershipEvent(membership, message) { return class extends Event { render() { super.render() - return this.text(text(this.data)) + return this.text(message(this.data)) } static canRender(event) { @@ -13,9 +13,20 @@ function createMembershipEvent(membership, text) { } } +class UnknownMembership extends Event { + render() { + super.render() + return this.text("Unsupported membership event") + } + + static canRender(event) { + return event.type == "m.room.member" + } + +} const JoinedEvent = createMembershipEvent("join", () => "joined the room") const InvitedEvent = createMembershipEvent("invite", (e) => `invited ${e.content.displayname} the room`) const LeaveEvent = createMembershipEvent("leave", () => "left the room") -module.exports = [JoinedEvent, InvitedEvent, LeaveEvent] +module.exports = [JoinedEvent, InvitedEvent, LeaveEvent, UnknownMembership]