From db8fab8019f2c8c681a6bb268f00fe470e86efac Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 27 Jan 2016 10:47:54 +0000 Subject: [PATCH 01/13] Redirect to the registration page when landing with ?email= Fixes "Missing access token" error. --- src/components/structures/MatrixChat.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 80489085ed..bcca9bad7d 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -96,6 +96,10 @@ module.exports = React.createClass({ if (!this.props.config || !this.props.config.default_hs_url) { console.error("Cannot enable guest access: No supplied config prop for HS/IS URLs"); } + else if (this.props.startingQueryParams.email) { + console.log("Not registering as guest; email invite."); + this._autoRegisterAsGuest = false; + } else { this._autoRegisterAsGuest = true; } @@ -634,6 +638,14 @@ module.exports = React.createClass({ action: 'start_post_registration', }); } else if (screen.indexOf('room/') == 0) { + + if (!this.state.logged_in && this.props.startingQueryParams.email) { + console.log("Redirecting to email registration"); + this.showScreen("register"); + this.notifyNewScreen('register'); // this doesn't call showScreen, just updates the hash + return; + } + var roomString = screen.split('/')[1]; if (roomString[0] == '#') { if (this.state.logged_in) { @@ -655,7 +667,7 @@ module.exports = React.createClass({ } } else { - if (screen) console.error("Unknown screen : %s", screen); + console.error("Unknown screen : %s", screen); } }, @@ -802,7 +814,6 @@ module.exports = React.createClass({ var RoomDirectory = sdk.getComponent('structures.RoomDirectory'); var MatrixToolbar = sdk.getComponent('globals.MatrixToolbar'); var ForgotPassword = sdk.getComponent('structures.login.ForgotPassword'); - // needs to be before normal PageTypes as you are logged in technically if (this.state.screen == 'post_registration') { return ( From e5f4fa8c467830745a77d281ab90347230a3b6c3 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 27 Jan 2016 17:58:47 +0000 Subject: [PATCH 02/13] Add warning bar for guest users. Fixes https://github.com/vector-im/vector-web/issues/770 --- src/components/structures/RoomView.js | 40 +++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index a2a308ed5c..12acdc21fd 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1474,6 +1474,16 @@ module.exports = React.createClass({ } }, + onRegisterClicked: function() { + dis.dispatch({'action': 'logout'}); + dis.dispatch({'action': 'start_registration'}); + }, + + onLoginClicked: function() { + dis.dispatch({'action': 'logout'}); + dis.dispatch({'action': 'start_login'}); + }, + render: function() { var RoomHeader = sdk.getComponent('rooms.RoomHeader'); var MessageComposer = sdk.getComponent('rooms.MessageComposer'); @@ -1581,13 +1591,13 @@ module.exports = React.createClass({ // a connection! if (this.state.syncState === "ERROR") { statusBar = ( -
+
/!\ -
-
+
+
Connectivity to the server has been lost.
-
+
Sent messages will be stored until your connection has returned.
@@ -1611,13 +1621,13 @@ module.exports = React.createClass({ } else if (this.state.hasUnsentMessages) { statusBar = ( -
+
/!\ -
-
+
+
Some of your messages have not been sent.
-
+ ); + } else if (MatrixClientPeg.get().isGuest()) { + statusBar = ( +
+ /!\ +
+
+ You are using Vector as a guest. +
+
+ Register or log in to access more rooms and features. +
+
+
+ ); } } From e01755976565102e47cb213a6f6170f820a95edd Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 28 Jan 2016 09:58:51 +0000 Subject: [PATCH 03/13] New line --- src/components/structures/MatrixChat.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index bcca9bad7d..a74964d0c8 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -814,6 +814,7 @@ module.exports = React.createClass({ var RoomDirectory = sdk.getComponent('structures.RoomDirectory'); var MatrixToolbar = sdk.getComponent('globals.MatrixToolbar'); var ForgotPassword = sdk.getComponent('structures.login.ForgotPassword'); + // needs to be before normal PageTypes as you are logged in technically if (this.state.screen == 'post_registration') { return ( From 7d621d88d84745d9a264dae98d5f6dcfc07eb297 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 28 Jan 2016 11:12:56 +0000 Subject: [PATCH 04/13] Your own messages should not count as unread --- src/Unread.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Unread.js b/src/Unread.js index 2b33fec829..d7490c8632 100644 --- a/src/Unread.js +++ b/src/Unread.js @@ -23,7 +23,9 @@ module.exports = { * count of unread messages */ eventTriggersUnreadCount: function(ev) { - if (ev.getType() == "m.room.member") { + if (ev.sender && ev.sender.userId == MatrixClientPeg.get().credentials.userId) { + return false; + } else if (ev.getType() == "m.room.member") { return false; } else if (ev.getType == 'm.room.message' && ev.getContent().msgtype == 'm.notify') { return false; From 796a2e5e3a18ebbaa60d01dd8b3478cbfeeac99a Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 28 Jan 2016 11:15:43 +0000 Subject: [PATCH 05/13] Revert e5f4fa8c467830745a77d281ab90347230a3b6c3 as it's no longer what's desired. --- src/components/structures/RoomView.js | 40 ++++++--------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 12acdc21fd..a2a308ed5c 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1474,16 +1474,6 @@ module.exports = React.createClass({ } }, - onRegisterClicked: function() { - dis.dispatch({'action': 'logout'}); - dis.dispatch({'action': 'start_registration'}); - }, - - onLoginClicked: function() { - dis.dispatch({'action': 'logout'}); - dis.dispatch({'action': 'start_login'}); - }, - render: function() { var RoomHeader = sdk.getComponent('rooms.RoomHeader'); var MessageComposer = sdk.getComponent('rooms.MessageComposer'); @@ -1591,13 +1581,13 @@ module.exports = React.createClass({ // a connection! if (this.state.syncState === "ERROR") { statusBar = ( -
+
/!\ -
-
+
+
Connectivity to the server has been lost.
-
+
Sent messages will be stored until your connection has returned.
@@ -1621,13 +1611,13 @@ module.exports = React.createClass({ } else if (this.state.hasUnsentMessages) { statusBar = ( -
+
/!\ -
-
+
+
Some of your messages have not been sent.
-
+ ); - } else if (MatrixClientPeg.get().isGuest()) { - statusBar = ( -
- /!\ -
-
- You are using Vector as a guest. -
-
- Register or log in to access more rooms and features. -
-
-
- ); } } From bdc1028a7eea9cea5f3cd55458ba4e547bcb87f2 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 28 Jan 2016 11:56:20 +0000 Subject: [PATCH 06/13] Support bulk invitations via text separators Valid separators are , ; --- src/components/views/rooms/MemberList.js | 28 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index 2d4fd39205..f2f0b03234 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -29,6 +29,8 @@ var SHARE_HISTORY_WARNING = "Newly invited users will see the history of this ro "turn off, 'Share message history with new users' in the settings for this room."; var shown_invite_warning_this_session = false; +// global promise so people can bulk invite and they all get resolved +var invite_defer = q.defer(); module.exports = React.createClass({ displayName: 'MemberList', @@ -158,6 +160,20 @@ module.exports = React.createClass({ var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); var self = this; inputText = inputText.trim(); // react requires es5-shim so we know trim() exists + + // email addresses and user IDs do not allow space, comma, semicolon so split + // on them for bulk inviting. + var separators =[ ";", " ", "," ]; + for (var i = 0; i < separators.length; i++) { + if (inputText.indexOf(separators[i]) >= 0) { + var inputs = inputText.split(separators[i]); + inputs.forEach(function(input) { + self.onInvite(input); + }); + return; + } + } + var isEmailAddress = /^\S+@\S+\.\S+$/.test(inputText); // sanity check the input for user IDs @@ -170,13 +186,14 @@ module.exports = React.createClass({ return; } - var invite_defer = q.defer(); + var inviteWarningDefer = q.defer(); var room = MatrixClientPeg.get().getRoom(this.props.roomId); var history_visibility = room.currentState.getStateEvents('m.room.history_visibility', ''); if (history_visibility) history_visibility = history_visibility.getContent().history_visibility; if (history_visibility == 'shared' && !shown_invite_warning_this_session) { + inviteWarningDefer = invite_defer; // whether we continue depends on this defer var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); Modal.createDialog(QuestionDialog, { title: "Warning", @@ -188,14 +205,17 @@ module.exports = React.createClass({ invite_defer.resolve(); } else { invite_defer.reject(null); + // reset the promise so we don't auto-reject all invites from + // now on. + invite_defer = q.defer(); } } }); } else { - invite_defer.resolve(); + inviteWarningDefer.resolve(); } - var promise = invite_defer.promise;; + var promise = inviteWarningDefer.promise; if (isEmailAddress) { promise = promise.then(function() { MatrixClientPeg.get().inviteByEmail(self.props.roomId, inputText); @@ -214,7 +234,7 @@ module.exports = React.createClass({ "Invite %s to %s - isEmail=%s", inputText, this.props.roomId, isEmailAddress ); promise.done(function(res) { - console.log("Invited"); + console.log("Invited %s", inputText); self.setState({ inviting: false }); From 83119d21d604319130ebdba7801bd7459bb08b52 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 28 Jan 2016 12:59:51 +0000 Subject: [PATCH 07/13] New style guest warning bar --- src/components/structures/MatrixChat.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 3184380005..0ac6e7f490 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -808,6 +808,7 @@ module.exports = React.createClass({ var CreateRoom = sdk.getComponent('structures.CreateRoom'); var RoomDirectory = sdk.getComponent('structures.RoomDirectory'); var MatrixToolbar = sdk.getComponent('globals.MatrixToolbar'); + var GuestWarningBar = sdk.getComponent('globals.GuestWarningBar'); var ForgotPassword = sdk.getComponent('structures.login.ForgotPassword'); // needs to be before normal PageTypes as you are logged in technically @@ -848,7 +849,20 @@ module.exports = React.createClass({ } // TODO: Fix duplication here and do conditionals like we do above - if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) { + if (MatrixClientPeg.get().isGuest()) { + return ( +
+ +
+ +
+ {page_element} +
+ {right_panel} +
+
+ ); + } else if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) { return (
From 401d18bcc622d1a77bcb9ff16fc7cc3c2f24ad89 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 28 Jan 2016 15:42:14 +0000 Subject: [PATCH 08/13] Fix registration: don't auto-log in as a guest if we have a URL from sydent. --- src/components/structures/MatrixChat.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index bf4258d990..e0f8ab96b3 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -100,6 +100,10 @@ module.exports = React.createClass({ console.log("Not registering as guest; email invite."); this._autoRegisterAsGuest = false; } + else if (this.props.startingQueryParams.client_secret && this.props.startingQueryParams.sid) { + console.log("Not registering as guest; registration."); + this._autoRegisterAsGuest = false; + } else { this._autoRegisterAsGuest = true; } From fe9d7d10b97df96642485cf8bdb8073a40697c8d Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 29 Jan 2016 21:48:32 -0500 Subject: [PATCH 09/13] Fix improper scrolldown button display issue. This fixes an intermittent issue where the scrolldown button or "new messages below" button would display even when the messages panel was scrolled to the very bottom. Furthermore, when new messages arrived, the messages panel would not automatically scroll down to show the new messages. Fixes https://github.com/vector-im/vector-web/issues/805 --- src/components/structures/ScrollPanel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/ScrollPanel.js b/src/components/structures/ScrollPanel.js index 8d26b2e365..e19b041219 100644 --- a/src/components/structures/ScrollPanel.js +++ b/src/components/structures/ScrollPanel.js @@ -160,8 +160,8 @@ module.exports = React.createClass({ // content. So don't call it in render() cycles. isAtBottom: function() { var sn = this._getScrollNode(); - // + 1 here to avoid fractional pixel rounding errors - return sn.scrollHeight - sn.scrollTop <= sn.clientHeight + 1; + // + 2 here to avoid fractional pixel rounding errors + return sn.scrollHeight - sn.scrollTop <= sn.clientHeight + 2; }, // check the scroll state and send out backfill requests if necessary. From e6c93530e257c9a0e7cbe08248ec19343d56dffa Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 1 Feb 2016 14:19:20 +0000 Subject: [PATCH 10/13] Strip trailing slashes on HS/IS URLs on register/login --- src/components/views/login/ServerConfig.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/login/ServerConfig.js b/src/components/views/login/ServerConfig.js index 741f0ebc69..fe80a0d61b 100644 --- a/src/components/views/login/ServerConfig.js +++ b/src/components/views/login/ServerConfig.js @@ -58,7 +58,7 @@ module.exports = React.createClass({ onHomeserverChanged: function(ev) { this.setState({hs_url: ev.target.value}, function() { this._hsTimeoutId = this._waitThenInvoke(this._hsTimeoutId, function() { - this.props.onHsUrlChanged(this.state.hs_url); + this.props.onHsUrlChanged(this.state.hs_url.replace(/\/$/, "")); }); }); }, @@ -66,7 +66,7 @@ module.exports = React.createClass({ onIdentityServerChanged: function(ev) { this.setState({is_url: ev.target.value}, function() { this._isTimeoutId = this._waitThenInvoke(this._isTimeoutId, function() { - this.props.onIsUrlChanged(this.state.is_url); + this.props.onIsUrlChanged(this.state.is_url.replace(/\/$/, "")); }); }); }, From c187eda832bedf924b9c3199b99900a27aa68ba0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 1 Feb 2016 16:53:39 +0000 Subject: [PATCH 11/13] Don't assert that we're not logged in before starting registration because uprading is now a thing. --- src/components/structures/MatrixChat.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index e0f8ab96b3..6050076d12 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -208,7 +208,6 @@ module.exports = React.createClass({ }); break; case 'start_registration': - if (this.state.logged_in) return; var newState = payload.params || {}; newState.screen = 'register'; if ( From 4e4e5be9a150780ede059ac5de0c369fa5c48228 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 2 Feb 2016 14:14:18 +0000 Subject: [PATCH 12/13] Disable upgrade registration temporarily. Fixes https://github.com/vector-im/vector-web/issues/818. --- src/components/structures/UserSettings.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index cadea6e220..9bf0793fc3 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -148,7 +148,8 @@ module.exports = React.createClass({ onUpgradeClicked: function() { dis.dispatch({ - action: "start_upgrade_registration" + //action: "start_upgrade_registration" + action: "start_registration" // temporary (https://github.com/vector-im/vector-web/issues/818) }); }, From 3b1ed3a0140a115ba3549b6860701d91d4164870 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 2 Feb 2016 17:59:11 +0000 Subject: [PATCH 13/13] Fix react warnings when a RR animation is happening during room switch If the animation of an RR removal is active when we change room, we end up getting a callback after the RoomView has been unmounted. Guard against this to avoid getting React warnings. --- src/components/structures/RoomView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index e2ed8231ef..37866ca646 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -915,7 +915,7 @@ module.exports = React.createClass({ var hr; hr = (
); ret.splice(ghostIndex, 0, (