From 48f162b9df39cf659042efa6dbab8d0a76672826 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 20 Oct 2015 14:03:37 +0100 Subject: [PATCH 01/16] Better error messages --- src/controllers/templates/Login.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js index c14ed28c4a..62cde0c5e5 100644 --- a/src/controllers/templates/Login.js +++ b/src/controllers/templates/Login.js @@ -94,8 +94,14 @@ module.exports = { self.setStep("stage_m.login.password"); if (error.httpStatus == 400 && loginParams.medium) { self.setState({errorText: 'This Home Server does not support login using email address.'}); - } else { - self.setState({errorText: 'Login failed.'}); + } + else if (error.httpStatus === 403) { + self.setState({errorText: 'The provided credentials are incorrect.'}); + } + else { + self.setState({ + errorText: 'There was a problem logging in. (HTTP ' + error.httpStatus + ")" + }); } }); }, From d1af5a2232ff71b7a23c2a5443c4dd945d38cb8b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 21 Oct 2015 14:30:59 +0100 Subject: [PATCH 02/16] More tweaks on error messages --- src/controllers/templates/Login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/templates/Login.js b/src/controllers/templates/Login.js index 62cde0c5e5..3472bf32ce 100644 --- a/src/controllers/templates/Login.js +++ b/src/controllers/templates/Login.js @@ -96,7 +96,7 @@ module.exports = { self.setState({errorText: 'This Home Server does not support login using email address.'}); } else if (error.httpStatus === 403) { - self.setState({errorText: 'The provided credentials are incorrect.'}); + self.setState({errorText: 'Incorrect username and/or password.'}); } else { self.setState({ From 0488f03b5af4e30e735bcfa077404d26af82776b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 21 Oct 2015 15:36:59 +0100 Subject: [PATCH 03/16] Remove empty controllers --- src/controllers/atoms/MessageTimestamp.js | 21 ------------------- src/controllers/atoms/voip/VideoFeed.js | 19 ----------------- src/controllers/molecules/EventAsTextTile.js | 19 ----------------- src/controllers/molecules/MImageTile.js | 21 ------------------- src/controllers/molecules/MRoomMemberTile.js | 21 ------------------- src/controllers/molecules/MatrixToolbar.js | 21 ------------------- src/controllers/molecules/SenderProfile.js | 21 ------------------- .../molecules/UnknownMessageTile.js | 20 ------------------ src/controllers/molecules/voip/VideoView.js | 19 ----------------- 9 files changed, 182 deletions(-) delete mode 100644 src/controllers/atoms/MessageTimestamp.js delete mode 100644 src/controllers/atoms/voip/VideoFeed.js delete mode 100644 src/controllers/molecules/EventAsTextTile.js delete mode 100644 src/controllers/molecules/MImageTile.js delete mode 100644 src/controllers/molecules/MRoomMemberTile.js delete mode 100644 src/controllers/molecules/MatrixToolbar.js delete mode 100644 src/controllers/molecules/SenderProfile.js delete mode 100644 src/controllers/molecules/UnknownMessageTile.js delete mode 100644 src/controllers/molecules/voip/VideoView.js diff --git a/src/controllers/atoms/MessageTimestamp.js b/src/controllers/atoms/MessageTimestamp.js deleted file mode 100644 index 8aa688b21e..0000000000 --- a/src/controllers/atoms/MessageTimestamp.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -module.exports = { -}; - diff --git a/src/controllers/atoms/voip/VideoFeed.js b/src/controllers/atoms/voip/VideoFeed.js deleted file mode 100644 index 3d34134daa..0000000000 --- a/src/controllers/atoms/voip/VideoFeed.js +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -module.exports = { -}; - diff --git a/src/controllers/molecules/EventAsTextTile.js b/src/controllers/molecules/EventAsTextTile.js deleted file mode 100644 index 3d34134daa..0000000000 --- a/src/controllers/molecules/EventAsTextTile.js +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -module.exports = { -}; - diff --git a/src/controllers/molecules/MImageTile.js b/src/controllers/molecules/MImageTile.js deleted file mode 100644 index 8aa688b21e..0000000000 --- a/src/controllers/molecules/MImageTile.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -module.exports = { -}; - diff --git a/src/controllers/molecules/MRoomMemberTile.js b/src/controllers/molecules/MRoomMemberTile.js deleted file mode 100644 index 8aa688b21e..0000000000 --- a/src/controllers/molecules/MRoomMemberTile.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -module.exports = { -}; - diff --git a/src/controllers/molecules/MatrixToolbar.js b/src/controllers/molecules/MatrixToolbar.js deleted file mode 100644 index 8aa688b21e..0000000000 --- a/src/controllers/molecules/MatrixToolbar.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -module.exports = { -}; - diff --git a/src/controllers/molecules/SenderProfile.js b/src/controllers/molecules/SenderProfile.js deleted file mode 100644 index 8aa688b21e..0000000000 --- a/src/controllers/molecules/SenderProfile.js +++ /dev/null @@ -1,21 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -module.exports = { -}; - diff --git a/src/controllers/molecules/UnknownMessageTile.js b/src/controllers/molecules/UnknownMessageTile.js deleted file mode 100644 index d0977e0043..0000000000 --- a/src/controllers/molecules/UnknownMessageTile.js +++ /dev/null @@ -1,20 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -'use strict'; - -module.exports = { -}; diff --git a/src/controllers/molecules/voip/VideoView.js b/src/controllers/molecules/voip/VideoView.js deleted file mode 100644 index 3d34134daa..0000000000 --- a/src/controllers/molecules/voip/VideoView.js +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2015 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -module.exports = { -}; - From ac5111c162111d4353fac9085362034730734c12 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 21 Oct 2015 17:44:05 +0100 Subject: [PATCH 04/16] Add missing enum value --- src/controllers/templates/Register.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/templates/Register.js b/src/controllers/templates/Register.js index 294329e42e..53d1ad1219 100644 --- a/src/controllers/templates/Register.js +++ b/src/controllers/templates/Register.js @@ -22,7 +22,8 @@ module.exports = { PasswordMismatch: 'PasswordMismatch', TooShort: 'TooShort', Missing: 'Missing', - InUse: 'InUse' + InUse: 'InUse', + Length: 'Length' }, getInitialState: function() { From a1444d3214f477eed625ec9b45ecb34ef1b4a272 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 26 Oct 2015 17:32:31 +0000 Subject: [PATCH 05/16] Linkify room aliases. Add listener for user ID clicks. --- src/linkify-matrix.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index e92a3efc91..8530fb2ddf 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -96,10 +96,21 @@ function matrixLinkify(linkify) { } matrixLinkify.options = { + events: function (href, type) { + if (type === "userid") { + return { + click: function(e) { + // sprout a MemberInfo context menu + console.log("Context => %s", href) + } + }; + } + }, + formatHref: function (href, type) { switch (type) { case 'roomalias': - return '#'; + return "#/room/" + href; case 'userid': return '#'; default: From 11ef1ac3368491ad321438a8f435d3a6dc8ee2f4 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 26 Oct 2015 17:36:03 +0000 Subject: [PATCH 06/16] Prevent the url from being butchered when clicking user IDs --- src/linkify-matrix.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index 8530fb2ddf..c74fb784b4 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -101,7 +101,8 @@ matrixLinkify.options = { return { click: function(e) { // sprout a MemberInfo context menu - console.log("Context => %s", href) + console.log("Context => %s", href); + e.preventDefault(); } }; } @@ -111,8 +112,6 @@ matrixLinkify.options = { switch (type) { case 'roomalias': return "#/room/" + href; - case 'userid': - return '#'; default: return href; } From 24ac8014173c3b114248dd9edb14aa1c9089b952 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 26 Oct 2015 17:59:49 +0000 Subject: [PATCH 07/16] Invoke onUserClick to allow impls to do whatever on user clicks. --- src/linkify-matrix.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index c74fb784b4..370bec7571 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -95,13 +95,14 @@ function matrixLinkify(linkify) { S_AT_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_USERID); } +matrixLinkify.onUserClick = function(e, userId) {}; + matrixLinkify.options = { events: function (href, type) { if (type === "userid") { return { click: function(e) { - // sprout a MemberInfo context menu - console.log("Context => %s", href); + matrixLinkify.onUserClick(e, href); e.preventDefault(); } }; @@ -116,6 +117,6 @@ matrixLinkify.options = { return href; } } -} +}; module.exports = matrixLinkify; From 77d1b9af041f49cec16a8276bb075e875a09685f Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 27 Oct 2015 09:58:55 +0000 Subject: [PATCH 08/16] Hook up aliases via listeners too. --- src/MatrixTools.js | 25 ++++++++++++++++++++++++ src/SlashCommands.js | 27 +++++++------------------- src/controllers/pages/MatrixChat.js | 22 ++++++++++++++++++++- src/linkify-matrix.js | 30 ++++++++++++++--------------- 4 files changed, 67 insertions(+), 37 deletions(-) diff --git a/src/MatrixTools.js b/src/MatrixTools.js index 5c6dca8b33..6c7a9ee9ba 100644 --- a/src/MatrixTools.js +++ b/src/MatrixTools.js @@ -31,6 +31,31 @@ module.exports = { } } return null; + }, + + /** + * Given a list of room objects, return the room which has the given alias, + * else null. + */ + getRoomForAlias: function(rooms, room_alias) { + var room; + for (var i = 0; i < rooms.length; i++) { + var aliasEvents = rooms[i].currentState.getStateEvents( + "m.room.aliases" + ); + for (var j = 0; j < aliasEvents.length; j++) { + var aliases = aliasEvents[j].getContent().aliases || []; + for (var k = 0; k < aliases.length; k++) { + if (aliases[k] === room_alias) { + room = rooms[i]; + break; + } + } + if (room) { break; } + } + if (room) { break; } + } + return room || null; } } diff --git a/src/SlashCommands.js b/src/SlashCommands.js index 08d68331f8..e6ea7533dc 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -15,6 +15,7 @@ limitations under the License. */ var MatrixClientPeg = require("./MatrixClientPeg"); +var MatrixTools = require("./MatrixTools"); var dis = require("./dispatcher"); var encryption = require("./encryption"); @@ -98,28 +99,14 @@ var commands = { } // Try to find a room with this alias - var rooms = MatrixClientPeg.get().getRooms(); - var roomId; - for (var i = 0; i < rooms.length; i++) { - var aliasEvents = rooms[i].currentState.getStateEvents( - "m.room.aliases" - ); - for (var j = 0; j < aliasEvents.length; j++) { - var aliases = aliasEvents[j].getContent().aliases || []; - for (var k = 0; k < aliases.length; k++) { - if (aliases[k] === room_alias) { - roomId = rooms[i].roomId; - break; - } - } - if (roomId) { break; } - } - if (roomId) { break; } - } - if (roomId) { // we've already joined this room, view it. + 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: roomId + room_id: foundRoom.roomId }); return success(); } diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index 2a712b22f6..e56d835267 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -21,6 +21,7 @@ var dis = require("../../dispatcher"); var sdk = require('../../index'); var MatrixTools = require('../../MatrixTools'); +var linkifyMatrix = require("../../linkify-matrix"); var Cas = require("../../CasLogic"); @@ -66,6 +67,13 @@ module.exports = { } else { this.notifyNewScreen('login'); } + + // this can technically be done anywhere but doing this here keeps all + // the routing url path logic together. + linkifyMatrix.onAliasClick = function(event, alias) { + dis.dispatch({action: 'view_room_alias', room_alias: alias}); + event.preventDefault(); + }; }, componentWillUnmount: function() { @@ -212,7 +220,19 @@ module.exports = { } break; case 'view_room_alias': - MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias).done(function(result) { + var foundRoom = MatrixTools.getRoomForAlias( + MatrixClientPeg.get().getRooms(), payload.room_alias + ); + if (foundRoom) { + dis.dispatch({ + action: 'view_room', + room_id: foundRoom.roomId + }); + return; + } + // resolve the alias and *then* view it + MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias).done( + function(result) { dis.dispatch({ action: 'view_room', room_id: result.room_id diff --git a/src/linkify-matrix.js b/src/linkify-matrix.js index 370bec7571..90b1938d51 100644 --- a/src/linkify-matrix.js +++ b/src/linkify-matrix.js @@ -95,26 +95,24 @@ function matrixLinkify(linkify) { S_AT_NAME_COLON_DOMAIN_DOT.on(TT.TLD, S_USERID); } -matrixLinkify.onUserClick = function(e, userId) {}; +matrixLinkify.onUserClick = function(e, userId) { e.preventDefault(); }; +matrixLinkify.onAliasClick = function(e, roomAlias) { e.preventDefault(); }; matrixLinkify.options = { events: function (href, type) { - if (type === "userid") { - return { - click: function(e) { - matrixLinkify.onUserClick(e, href); - e.preventDefault(); - } - }; - } - }, - - formatHref: function (href, type) { switch (type) { - case 'roomalias': - return "#/room/" + href; - default: - return href; + case "userid": + return { + click: function(e) { + matrixLinkify.onUserClick(e, href); + } + }; + case "roomalias": + return { + click: function(e) { + matrixLinkify.onAliasClick(e, href); + } + }; } } }; From 16ddb47466069a0654a29deb5182818b9b94fcc2 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 27 Oct 2015 10:44:41 +0000 Subject: [PATCH 09/16] Defer entirely to the end app for handling links --- src/controllers/pages/MatrixChat.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index e56d835267..e1f6afb95e 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -70,10 +70,12 @@ module.exports = { // this can technically be done anywhere but doing this here keeps all // the routing url path logic together. - linkifyMatrix.onAliasClick = function(event, alias) { - dis.dispatch({action: 'view_room_alias', room_alias: alias}); - event.preventDefault(); - }; + if (this.onAliasClick) { + linkifyMatrix.onAliasClick = this.onAliasClick; + } + if (this.onUserClick) { + linkifyMatrix.onUserClick = this.onUserClick; + } }, componentWillUnmount: function() { From 2a1b9cd71689a1dba0dcde2ff89eb0d0e01cdc28 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Tue, 27 Oct 2015 17:01:03 +0000 Subject: [PATCH 10/16] Add creatingRoom state to know when to show a spinner. --- src/controllers/molecules/MemberInfo.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/controllers/molecules/MemberInfo.js b/src/controllers/molecules/MemberInfo.js index 24e4afe5fd..23ae2e5fb1 100644 --- a/src/controllers/molecules/MemberInfo.js +++ b/src/controllers/molecules/MemberInfo.js @@ -161,6 +161,7 @@ module.exports = { onChatClick: function() { // check if there are any existing rooms with just us and them (1:1) // If so, just view that room. If not, create a private room with them. + var self = this; var rooms = MatrixClientPeg.get().getRooms(); var userIds = [ this.props.member.userId, @@ -189,23 +190,28 @@ module.exports = { action: 'view_room', room_id: existingRoomId }); + this.props.onFinished(); } else { + self.setState({ creatingRoom: true }); MatrixClientPeg.get().createRoom({ invite: [this.props.member.userId], preset: "private_chat" }).done(function(res) { + self.setState({ creatingRoom: false }); dis.dispatch({ action: 'view_room', room_id: res.room_id }); + self.props.onFinished(); }, function(err) { + self.setState({ creatingRoom: false }); console.error( "Failed to create room: %s", JSON.stringify(err) ); + self.props.onFinished(); }); } - this.props.onFinished(); }, // FIXME: this is horribly duplicated with MemberTile's onLeaveClick. @@ -249,7 +255,8 @@ module.exports = { modifyLevel: false }, muted: false, - isTargetMod: false + isTargetMod: false, + creatingRoom: false } }, From 966f44baa190cd367a50383561f24d3f9fe40224 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 28 Oct 2015 18:06:10 +0000 Subject: [PATCH 11/16] bump js-sdk -> 0.3.0 on the right branch --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f28cfdf215..ff7d75e712 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "flux": "^2.0.3", "glob": "^5.0.14", "linkifyjs": "^2.0.0-beta.4", - "matrix-js-sdk": "^0.2.2", + "matrix-js-sdk": "^0.3.0", "optimist": "^0.6.1", "q": "^1.4.1", "react": "^0.13.3", From 9df7337a6d07c982ac72c432e820064c8b07d946 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 29 Oct 2015 10:14:37 +0000 Subject: [PATCH 12/16] actually commit ability to apply a custom class to modal dialogs, used for lightboxing --- src/Modal.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Modal.js b/src/Modal.js index 8566022060..bf7758a1a8 100644 --- a/src/Modal.js +++ b/src/Modal.js @@ -34,7 +34,7 @@ module.exports = { return container; }, - createDialogWithElement: function(element, props) { + createDialogWithElement: function(element, props, className) { var self = this; var closeDialog = function() { @@ -44,7 +44,7 @@ module.exports = { }; var dialog = ( -
+
{element}
@@ -57,7 +57,7 @@ module.exports = { return {close: closeDialog}; }, - createDialog: function (Element, props) { + createDialog: function (Element, props, className) { var self = this; var closeDialog = function() { @@ -69,7 +69,7 @@ module.exports = { // FIXME: If a dialog uses getDefaultProps it clobbers the onFinished // property set here so you can't close the dialog from a button click! var dialog = ( -
+
From 40da7f500e6317cd68e6ebd6c7cf16236476b6e5 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 30 Oct 2015 02:07:04 +0000 Subject: [PATCH 13/16] show m.room.name changes --- src/TextForEvent.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index 71354325bd..d784fa7c38 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -1,6 +1,6 @@ function textForMemberEvent(ev) { - // XXX: SYJS-16 + // XXX: SYJS-16 "sender is sometimes null for join messages" var senderName = ev.sender ? ev.sender.name : ev.getSender(); var targetName = ev.target ? ev.target.name : ev.getStateKey(); var reason = ev.getContent().reason ? ( @@ -58,6 +58,12 @@ function textForTopicEvent(ev) { return senderDisplayName + ' changed the topic to, "' + ev.getContent().topic + '"'; }; +function textForRoomNameEvent(ev) { + var senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(); + + return senderDisplayName + ' changed the room name to "' + ev.getContent().name + '"'; +}; + function textForMessageEvent(ev) { var senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender(); @@ -93,11 +99,12 @@ function textForCallInviteEvent(event) { var handlers = { 'm.room.message': textForMessageEvent, - 'm.room.topic': textForTopicEvent, - 'm.room.member': textForMemberEvent, - 'm.call.invite': textForCallInviteEvent, - 'm.call.answer': textForCallAnswerEvent, - 'm.call.hangup': textForCallHangupEvent, + 'm.room.name': textForRoomNameEvent, + 'm.room.topic': textForTopicEvent, + 'm.room.member': textForMemberEvent, + 'm.call.invite': textForCallInviteEvent, + 'm.call.answer': textForCallAnswerEvent, + 'm.call.hangup': textForCallHangupEvent, }; module.exports = { From e792201cd61ef3cbfdbad3bb1994655ec7b305aa Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 31 Oct 2015 14:00:23 +0000 Subject: [PATCH 14/16] back out ctrl-alt-number room switching as nobody used it and it broke Tor's keyboard --- src/controllers/pages/MatrixChat.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js index e1f6afb95e..a38ba8e4e7 100644 --- a/src/controllers/pages/MatrixChat.js +++ b/src/controllers/pages/MatrixChat.js @@ -344,6 +344,9 @@ module.exports = { onKeyDown: function(ev) { if (ev.altKey) { + /* + // Remove this for now as ctrl+alt = alt-gr so this breaks keyboards which rely on alt-gr for numbers + // Will need to find a better meta key if anyone actually cares about using this. if (ev.ctrlKey && ev.keyCode > 48 && ev.keyCode < 58) { dis.dispatch({ action: 'view_indexed_room', @@ -353,6 +356,7 @@ module.exports = { ev.preventDefault(); return; } + */ switch (ev.keyCode) { case 38: dis.dispatch({action: 'view_prev_room'}); From 3485a740368969c4b9bdfc633b4c779dcccabaa5 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 2 Nov 2015 17:39:00 +0000 Subject: [PATCH 15/16] Gracefully handle browsers which don't do VoIP Specifically: - Don't show inbound call ringing - Don't let users place calls/conf calls - Show call records with "not supported by this browser". --- src/CallHandler.js | 28 +++++++++++++++++++++++++--- src/TextForEvent.js | 10 +++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index cf8460db6c..b3af0e8337 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -173,17 +173,27 @@ function _onAction(payload) { console.error("Unknown conf call type: %s", payload.type); } } + var ErrorDialog = sdk.getComponent("organisms.ErrorDialog"); switch (payload.action) { case 'place_call': if (module.exports.getAnyActiveCall()) { - var ErrorDialog = sdk.getComponent("organisms.ErrorDialog"); Modal.createDialog(ErrorDialog, { title: "Existing Call", description: "You are already in a call." }); return; // don't allow >1 call to be placed. } + + // if the runtime env doesn't do VoIP, whine. + if (!MatrixClientPeg.get().supportsVoip()) { + Modal.createDialog(ErrorDialog, { + title: "VoIP is unsupported", + description: "You cannot place VoIP calls in this browser." + }); + return; + } + var room = MatrixClientPeg.get().getRoom(payload.room_id); if (!room) { console.error("Room %s does not exist.", payload.room_id); @@ -218,11 +228,17 @@ function _onAction(payload) { case 'place_conference_call': console.log("Place conference call in %s", payload.room_id); if (!Modulator.hasConferenceHandler()) { - var ErrorDialog = sdk.getComponent("organisms.ErrorDialog"); Modal.createDialog(ErrorDialog, { description: "Conference calls are not supported in this client" }); - } else { + } + else if (!MatrixClientPeg.get().supportsVoip()) { + Modal.createDialog(ErrorDialog, { + title: "VoIP is unsupported", + description: "You cannot place VoIP calls in this browser." + }); + } + else { var ConferenceHandler = Modulator.getConferenceHandler(); ConferenceHandler.createNewMatrixCall( MatrixClientPeg.get(), payload.room_id @@ -238,6 +254,12 @@ function _onAction(payload) { payload.call.hangup("busy"); return; // don't allow >1 call to be received, hangup newer one. } + + // if the runtime env doesn't do VoIP, stop here. + if (!MatrixClientPeg.get().supportsVoip()) { + return; + } + var call = payload.call; _setCallListeners(call); _setCallState(call, call.roomId, "ringing"); diff --git a/src/TextForEvent.js b/src/TextForEvent.js index d784fa7c38..439d7b9ef5 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -1,3 +1,4 @@ +var MatrixClientPeg = require("./MatrixClientPeg"); function textForMemberEvent(ev) { // XXX: SYJS-16 "sender is sometimes null for join messages" @@ -78,12 +79,14 @@ function textForMessageEvent(ev) { function textForCallAnswerEvent(event) { var senderName = event.sender ? event.sender.name : "Someone"; - return senderName + " answered the call."; + var supported = MatrixClientPeg.get().supportsVoip() ? "" : " (not supported by this browser)"; + return senderName + " answered the call." + supported; }; function textForCallHangupEvent(event) { var senderName = event.sender ? event.sender.name : "Someone"; - return senderName + " ended the call."; + var supported = MatrixClientPeg.get().supportsVoip() ? "" : " (not supported by this browser)"; + return senderName + " ended the call." + supported; }; function textForCallInviteEvent(event) { @@ -94,7 +97,8 @@ function textForCallInviteEvent(event) { event.getContent().offer.sdp.indexOf('m=video') !== -1) { type = "video"; } - return senderName + " placed a " + type + " call."; + var supported = MatrixClientPeg.get().supportsVoip() ? "" : " (not supported by this browser)"; + return senderName + " placed a " + type + " call." + supported; }; var handlers = { From 3fec3a7326a995299c0f26f2e867d5880ee303c0 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 3 Nov 2015 18:29:49 +0000 Subject: [PATCH 16/16] Better error message if there is no accessSync (which there isn't on old node) --- reskindex.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reskindex.js b/reskindex.js index f8d45493d3..e028979122 100755 --- a/reskindex.js +++ b/reskindex.js @@ -18,7 +18,7 @@ var skin = args._[0]; try { fs.accessSync(path.join('src', 'skins', skin), fs.F_OK); } catch (e) { - console.log("Skin "+skin+" not found"); + console.log("Skin "+skin+" not found: "+e); process.exit(1); }