From 970bc84bb6f677317cc182f0b7dc541e34434680 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 28 Dec 2015 02:58:40 +0000 Subject: [PATCH] explicitly rejoin parted rooms --- src/SlashCommands.js | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index e6ea7533dc..f5eaff9066 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -99,29 +99,33 @@ var commands = { } // Try to find a room with this alias + // XXX: do we need to do this? Doesn't the JS SDK suppress duplicate attempts to join the same room? var foundRoom = MatrixTools.getRoomForAlias( MatrixClientPeg.get().getRooms(), room_alias ); - if (foundRoom) { // we've already joined this room, view it. - dis.dispatch({ - action: 'view_room', - room_id: foundRoom.roomId - }); - return success(); - } - else { - // attempt to join this alias. - return success( - MatrixClientPeg.get().joinRoom(room_alias).then( - function(room) { - dis.dispatch({ - action: 'view_room', - room_id: room.roomId - }); - }) - ); + + if (foundRoom) { // we've already joined this room, view it if it's not archived. + var me = foundRoom.getMember(MatrixClientPeg.get().credentials.userId); + if (me && me.membership !== "leave") { + dis.dispatch({ + action: 'view_room', + room_id: foundRoom.roomId + }); + return success(); + } } + + // otherwise attempt to join this alias. + return success( + MatrixClientPeg.get().joinRoom(room_alias).then( + function(room) { + dis.dispatch({ + action: 'view_room', + room_id: room.roomId + }); + }) + ); } } return reject("Usage: /join ");