From 3060ec10535e1be1850b809c24c18d97eea24b9b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 25 Jan 2018 09:54:31 +0000 Subject: [PATCH 1/2] Use invite_3pid prop of createRoom instead of manual invite after create Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/RoomInvite.js | 13 ++++++++++--- src/createRoom.js | 13 ++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/RoomInvite.js b/src/RoomInvite.js index 1979c6d111..31541148d9 100644 --- a/src/RoomInvite.js +++ b/src/RoomInvite.js @@ -85,9 +85,7 @@ function _onStartChatFinished(shouldInvite, addrs) { if (rooms.length > 0) { // A Direct Message room already exists for this user, so select a // room from a list that is similar to the one in MemberInfo panel - const ChatCreateOrReuseDialog = sdk.getComponent( - "views.dialogs.ChatCreateOrReuseDialog", - ); + const ChatCreateOrReuseDialog = sdk.getComponent("views.dialogs.ChatCreateOrReuseDialog"); const close = Modal.createTrackedDialog('Create or Reuse', '', ChatCreateOrReuseDialog, { userId: addrTexts[0], onNewDMClick: () => { @@ -115,6 +113,15 @@ function _onStartChatFinished(shouldInvite, addrs) { }); }); } + } else if (addrTexts.length === 1) { + // Start a new DM chat + createRoom({dmUserId: addrTexts[0]}).catch((err) => { + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + Modal.createTrackedDialog('Failed to invite user', '', ErrorDialog, { + title: _t("Failed to invite user"), + description: ((err && err.message) ? err.message : _t("Operation failed")), + }); + }); } else { // Start multi user chat let room; diff --git a/src/createRoom.js b/src/createRoom.js index ffe3a85c4e..a767d09288 100644 --- a/src/createRoom.js +++ b/src/createRoom.js @@ -22,6 +22,7 @@ import dis from "./dispatcher"; import * as Rooms from "./Rooms"; import Promise from 'bluebird'; +import {getAddressType} from "./UserAddress"; /** * Create a new room, and switch to it. @@ -52,7 +53,17 @@ function createRoom(opts) { createOpts.preset = createOpts.preset || defaultPreset; createOpts.visibility = createOpts.visibility || 'private'; if (opts.dmUserId && createOpts.invite === undefined) { - createOpts.invite = [opts.dmUserId]; + switch (getAddressType(opts.dmUserId)) { + case 'mx-user-id': + createOpts.invite = [opts.dmUserId]; + break; + case 'email': + createOpts.invite_3pid = [{ + id_server: MatrixClientPeg.get().getIdentityServerUrl(true), + medium: 'email', + address: opts.dmUserId, + }]; + } } if (opts.dmUserId && createOpts.is_direct === undefined) { createOpts.is_direct = true; From 8a6727ea98ea8034bbe79d29d6e6bc6585dbff43 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 Jan 2018 10:55:23 +0000 Subject: [PATCH 2/2] This is actually MFileBody not MImageBody, change classname Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/messages/MFileBody.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/views/messages/MFileBody.js b/src/components/views/messages/MFileBody.js index d106d7368e..c324c291e7 100644 --- a/src/components/views/messages/MFileBody.js +++ b/src/components/views/messages/MFileBody.js @@ -295,7 +295,7 @@ module.exports = React.createClass({ return ( -
+
{ _t("Decrypt %(text)s", { text: text }) } @@ -327,7 +327,7 @@ module.exports = React.createClass({ } return ( -
+
{ /* * Add dummy copy of the "a" tag @@ -347,7 +347,7 @@ module.exports = React.createClass({ if (this.props.tileShape === "file_grid") { return ( -
+
{ fileName } @@ -360,7 +360,7 @@ module.exports = React.createClass({ } else { return ( -