From 5fb6ea94b2ac0b2e3d88012c6010bc4b9323086f Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 22 Jul 2015 10:59:36 +0100 Subject: [PATCH 1/6] Add leave button as per wireframes --- skins/base/css/molecules/MemberTile.css | 9 ++++-- skins/base/views/molecules/MemberTile.js | 35 ++++++++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/skins/base/css/molecules/MemberTile.css b/skins/base/css/molecules/MemberTile.css index 099542a87..fcfc60a00 100644 --- a/skins/base/css/molecules/MemberTile.css +++ b/skins/base/css/molecules/MemberTile.css @@ -33,7 +33,7 @@ limitations under the License. .mx_MemberTile_avatarImg { z-index: 20; - border-radius: 20px; + border-radius: 20px; background-color: #dbdbdb; } @@ -96,4 +96,9 @@ limitations under the License. .mx_MemberTile_offline .mx_MemberTile_nameSpan { opacity: 0.5; -} \ No newline at end of file +} + + +.mx_MemberTile_leave { + float: right; +} diff --git a/skins/base/views/molecules/MemberTile.js b/skins/base/views/molecules/MemberTile.js index 9583c3c4d..3e5887446 100644 --- a/skins/base/views/molecules/MemberTile.js +++ b/skins/base/views/molecules/MemberTile.js @@ -20,8 +20,10 @@ var React = require('react'); var MatrixClientPeg = require("../../../../src/MatrixClientPeg"); var ComponentBroker = require('../../../../src/ComponentBroker'); +var Modal = require("../../../../src/Modal"); var MemberTileController = require("../../../../src/controllers/molecules/MemberTile"); var MemberInfo = ComponentBroker.get('molecules/MemberInfo'); +var ErrorDialog = ComponentBroker.get("organisms/ErrorDialog"); module.exports = React.createClass({ displayName: 'MemberTile', @@ -40,7 +42,23 @@ module.exports = React.createClass({ this.setState({ 'hover': false }); }, + onLeaveClick: function() { + var d = MatrixClientPeg.get().leave(this.props.member.roomId); + // TODO: Add spinner + + d.then(function() { + // TODO: Change to another room. + }, function(err) { + Modal.createDialog(ErrorDialog, { + title: "Failed to leave room", + description: err.toString() + }); + }); + }, + render: function() { + var isMyUser = MatrixClientPeg.get().credentials.userId == this.props.member.userId; + var power; if (this.props.member) { var img = "img/p/p" + Math.floor(20 * this.props.member.powerLevelNorm / 100) + ".png"; @@ -58,18 +76,23 @@ module.exports = React.createClass({ } mainClassName += presenceClass; - var name; + var name = this.props.member.name; + if (isMyUser) name += " (me)"; + var leave = isMyUser ? X : null; + var nameEl; if (this.state.hover) { - name = + nameEl =
- {this.props.member.name} + {name} + {leave}
} else { - name = + nameEl =
- {this.props.member.name} + {name} + {leave}
} @@ -81,7 +104,7 @@ module.exports = React.createClass({ width="40" height="40" alt=""/> { power } - { name } + { nameEl } ); } From 5835ea0a9773d21f29c6adb9e631d6576c13192b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 22 Jul 2015 11:33:46 +0100 Subject: [PATCH 2/6] Only display rooms you're currently joined to in recents --- src/controllers/organisms/RoomList.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/organisms/RoomList.js b/src/controllers/organisms/RoomList.js index 4adeaf2e2..950f2e10b 100644 --- a/src/controllers/organisms/RoomList.js +++ b/src/controllers/organisms/RoomList.js @@ -96,7 +96,14 @@ module.exports = { }, getRoomList: function() { - return RoomListSorter.mostRecentActivityFirst(MatrixClientPeg.get().getRooms()); + return RoomListSorter.mostRecentActivityFirst( + MatrixClientPeg.get().getRooms().filter(function(room) { + return room.hasMembershipState( + MatrixClientPeg.get().credentials.userId, + "join" + ); + }) + ); }, makeRoomTiles: function() { From 6bfc566d9acc7934ce30856eff73a3e0c3bab998 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 22 Jul 2015 11:41:32 +0100 Subject: [PATCH 3/6] Switch to another room when we succesfully leave a room --- skins/base/views/molecules/MemberTile.js | 14 -------------- src/controllers/molecules/MemberTile.js | 15 +++++++++++++++ src/controllers/organisms/RoomList.js | 1 - 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/skins/base/views/molecules/MemberTile.js b/skins/base/views/molecules/MemberTile.js index 3e5887446..574be2254 100644 --- a/skins/base/views/molecules/MemberTile.js +++ b/skins/base/views/molecules/MemberTile.js @@ -42,20 +42,6 @@ module.exports = React.createClass({ this.setState({ 'hover': false }); }, - onLeaveClick: function() { - var d = MatrixClientPeg.get().leave(this.props.member.roomId); - // TODO: Add spinner - - d.then(function() { - // TODO: Change to another room. - }, function(err) { - Modal.createDialog(ErrorDialog, { - title: "Failed to leave room", - description: err.toString() - }); - }); - }, - render: function() { var isMyUser = MatrixClientPeg.get().credentials.userId == this.props.member.userId; diff --git a/src/controllers/molecules/MemberTile.js b/src/controllers/molecules/MemberTile.js index 811d2a78b..20ace568a 100644 --- a/src/controllers/molecules/MemberTile.js +++ b/src/controllers/molecules/MemberTile.js @@ -27,4 +27,19 @@ module.exports = { user_id: this.props.member.userId }); }, + + onLeaveClick: function() { + var d = MatrixClientPeg.get().leave(this.props.member.roomId); + // TODO: Add spinner + + d.then(function() { + // TODO: Change to another room. + dis.dispatch({action: 'view_next_room'}); + }, function(err) { + Modal.createDialog(ErrorDialog, { + title: "Failed to leave room", + description: err.toString() + }); + }); + } }; diff --git a/src/controllers/organisms/RoomList.js b/src/controllers/organisms/RoomList.js index 950f2e10b..054e5f4e1 100644 --- a/src/controllers/organisms/RoomList.js +++ b/src/controllers/organisms/RoomList.js @@ -122,4 +122,3 @@ module.exports = { }); }, }; - From ed1cb44deb95db1104753798b017393d848476cf Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 22 Jul 2015 13:39:36 +0100 Subject: [PATCH 4/6] Show Loader while leaving --- src/Modal.js | 2 ++ src/controllers/molecules/MemberTile.js | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Modal.js b/src/Modal.js index a8331e554..1e3ded42b 100644 --- a/src/Modal.js +++ b/src/Modal.js @@ -56,5 +56,7 @@ module.exports = { ); React.render(dialog, this.getOrCreateContainer()); + + return {close: closeDialog}; }, }; diff --git a/src/controllers/molecules/MemberTile.js b/src/controllers/molecules/MemberTile.js index 20ace568a..5d1f99a6f 100644 --- a/src/controllers/molecules/MemberTile.js +++ b/src/controllers/molecules/MemberTile.js @@ -17,6 +17,8 @@ limitations under the License. 'use strict'; var dis = require("../../dispatcher"); +var Modal = require("../../Modal"); +var Loader = require("react-loader"); var MatrixClientPeg = require("../../MatrixClientPeg"); @@ -30,12 +32,14 @@ module.exports = { onLeaveClick: function() { var d = MatrixClientPeg.get().leave(this.props.member.roomId); - // TODO: Add spinner + + var modal = Modal.createDialog(Loader); d.then(function() { - // TODO: Change to another room. + modal.close(); dis.dispatch({action: 'view_next_room'}); }, function(err) { + modal.close(); Modal.createDialog(ErrorDialog, { title: "Failed to leave room", description: err.toString() From 0016c2ad83afd85fc3941e6218d86bd65c2cf478 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 22 Jul 2015 13:47:08 +0100 Subject: [PATCH 5/6] Also change URL when going to next/prev room --- src/controllers/pages/MatrixChat.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index 73f526c23..d43fd1e4c 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -153,6 +153,7 @@ module.exports = { this.setState({ currentRoom: allRooms[roomIndex].roomId }); + this.notifyNewScreen('room/'+allRooms[roomIndex].roomId); break; case 'view_user_settings': this.setState({ From 431c93fc29f71254ca296a73827968ad0a83e8cd Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 22 Jul 2015 13:57:48 +0100 Subject: [PATCH 6/6] Fix invites so they display in room list --- src/controllers/organisms/RoomList.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/controllers/organisms/RoomList.js b/src/controllers/organisms/RoomList.js index 054e5f4e1..423197067 100644 --- a/src/controllers/organisms/RoomList.js +++ b/src/controllers/organisms/RoomList.js @@ -98,10 +98,8 @@ module.exports = { getRoomList: function() { return RoomListSorter.mostRecentActivityFirst( MatrixClientPeg.get().getRooms().filter(function(room) { - return room.hasMembershipState( - MatrixClientPeg.get().credentials.userId, - "join" - ); + var member = room.getMember(MatrixClientPeg.get().credentials.userId); + return member && (member.membership == "join" || member.membership == "invite"); }) ); },