From a21b6e61a693ccfef18134bd5148ff479fc97101 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 9 Jun 2017 10:08:26 +0100 Subject: [PATCH 1/3] Default to home page when settings is closed If the current room isn't set. --- src/components/structures/MatrixChat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index b6e3552a95..61b1dd4a38 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1307,7 +1307,7 @@ module.exports = React.createClass({ }); } else { dis.dispatch({ - action: 'view_room_directory', + action: 'view_home_page', }); } }, From c7229967a663ad6b6ae3a04700288a8dcf8478c5 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 9 Jun 2017 10:28:45 +0100 Subject: [PATCH 2/3] Goto /home when forgetting the last room --- src/components/structures/MatrixChat.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index b6e3552a95..9e59e8ea5c 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -570,6 +570,12 @@ module.exports = React.createClass({ const allRooms = RoomListSorter.mostRecentActivityFirst( MatrixClientPeg.get().getRooms(), ); + if (allRooms.length === 0) { + dis.dispatch({ + action: 'view_home_page', + }); + return; + } let roomIndex = -1; for (let i = 0; i < allRooms.length; ++i) { if (allRooms[i].roomId == this.state.currentRoomId) { From 19bb879fbf3858d40c4e28d08af53479a9989199 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Fri, 9 Jun 2017 10:54:42 +0100 Subject: [PATCH 3/3] Handle only 1 room in the list --- src/components/structures/MatrixChat.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 9e59e8ea5c..fae2b831d5 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -570,7 +570,10 @@ module.exports = React.createClass({ const allRooms = RoomListSorter.mostRecentActivityFirst( MatrixClientPeg.get().getRooms(), ); - if (allRooms.length === 0) { + // If there are 0 rooms or 1 room, view the home page because otherwise + // if there are 0, we end up trying to index into an empty array, and + // if there is 1, we end up viewing the same room. + if (allRooms.length < 2) { dis.dispatch({ action: 'view_home_page', });