From fa3387b3267ef2924521f696cedeafc6792b766f Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 6 Sep 2016 10:29:38 +0100 Subject: [PATCH] Code review - use an empty state key - swap switch for if - s/not in view/not visible/ --- src/ScalarMessaging.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index 857ef1e3c7..840bc3ee86 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -196,7 +196,7 @@ function getMembershipState(event, roomId, userId) { function getJoinRules(event, roomId) { console.log(`join_rules of ${roomId} requested.`); - returnStateEvent(event, roomId, "m.room.join_rules"); + returnStateEvent(event, roomId, "m.room.join_rules", ""); } function botOptions(event, roomId, userId) { @@ -228,11 +228,10 @@ var currentRoomId = null; // Listen for when a room is viewed dis.register(onAction); function onAction(payload) { - switch (payload.action) { - case 'view_room': - currentRoomId = payload.room_id; - break; + if (payload.action !== "view_room") + return; } + currentRoomId = payload.room_id; } const onMessage = function(event) { @@ -265,7 +264,7 @@ const onMessage = function(event) { return; } if (roomId !== currentRoomId) { - sendError(event, "Room " + roomId + " not in view"); + sendError(event, "Room " + roomId + " not visible"); return; }