From 194cd0a46063404e9c5f9906183bc095a66b711f Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 9 Sep 2019 13:53:56 +0100
Subject: [PATCH 1/3] Fix identity server text in AddressPickerDialog
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/views/dialogs/AddressPickerDialog.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js
index 8f0a42198e..91088d2261 100644
--- a/src/components/views/dialogs/AddressPickerDialog.js
+++ b/src/components/views/dialogs/AddressPickerDialog.js
@@ -678,7 +678,7 @@ module.exports = createReactClass({
}
let identityServer;
- if (this.props.pickerType === 'user' && !this.state.validAddressTypes.includes('email')) {
+ if (this.props.pickerType === 'user' && this.props.validAddressTypes.includes('email')) {
const defaultIdentityServerUrl = getDefaultIdentityServerUrl();
if (defaultIdentityServerUrl) {
identityServer =
{_t(
From 043a8d35e665b645e1c8ed4c2c89d297bb4e3352 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 9 Sep 2019 15:03:00 +0100
Subject: [PATCH 2/3] Move the rest of the IS/email supported logic to
AddressPickerDialog
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/RoomInvite.js | 5 +----
.../views/dialogs/AddressPickerDialog.js | 14 +++++++++++---
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/RoomInvite.js b/src/RoomInvite.js
index 856a2ca577..ea5bf847ad 100644
--- a/src/RoomInvite.js
+++ b/src/RoomInvite.js
@@ -43,10 +43,7 @@ function inviteMultipleToRoom(roomId, addrs) {
export function showStartChatInviteDialog() {
const AddressPickerDialog = sdk.getComponent("dialogs.AddressPickerDialog");
- const validAddressTypes = ['mx-user-id'];
- if (MatrixClientPeg.get().getIdentityServerUrl()) {
- validAddressTypes.push('email');
- }
+ const validAddressTypes = ['mx-user-id', 'email'];
Modal.createTrackedDialog('Start a chat', '', AddressPickerDialog, {
title: _t('Start a chat'),
diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js
index 91088d2261..32c5cf6900 100644
--- a/src/components/views/dialogs/AddressPickerDialog.js
+++ b/src/components/views/dialogs/AddressPickerDialog.js
@@ -77,6 +77,12 @@ module.exports = createReactClass({
},
getInitialState: function() {
+ let validAddressTypes = this.props.validAddressTypes;
+ // Remove email from validAddressTypes if no IS is configured. It may be added at a later stage by the user
+ if (!MatrixClientPeg.get().getIdentityServerUrl() && validAddressTypes.includes("email")) {
+ validAddressTypes = validAddressTypes.splice(validAddressTypes.indexOf("email"), 1);
+ }
+
return {
// Whether to show an error message because of an invalid address
invalidAddressError: false,
@@ -95,8 +101,8 @@ module.exports = createReactClass({
// auto-completion results for the current search query.
suggestedList: [],
// List of address types initialised from props, but may change while the
- // dialog is open.
- validAddressTypes: this.props.validAddressTypes,
+ // dialog is open and represents the supported list of address types at this time.
+ validAddressTypes,
};
},
@@ -678,7 +684,9 @@ module.exports = createReactClass({
}
let identityServer;
- if (this.props.pickerType === 'user' && this.props.validAddressTypes.includes('email')) {
+ // If picker cannot currently accept e-mail but should be able to
+ if (this.props.pickerType === 'user' && !this.state.validAddressTypes.includes('email')
+ && this.props.validAddressTypes.includes('email')) {
const defaultIdentityServerUrl = getDefaultIdentityServerUrl();
if (defaultIdentityServerUrl) {
identityServer =
{_t(
From a40ecda9932fc5733c88f2806a745c8ab4d2ec49 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 12 Sep 2019 12:34:14 +0100
Subject: [PATCH 3/3] Fix missed case of validAddressTypes being conditional
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/RoomInvite.js | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/RoomInvite.js b/src/RoomInvite.js
index ea5bf847ad..19cbef4242 100644
--- a/src/RoomInvite.js
+++ b/src/RoomInvite.js
@@ -43,8 +43,6 @@ function inviteMultipleToRoom(roomId, addrs) {
export function showStartChatInviteDialog() {
const AddressPickerDialog = sdk.getComponent("dialogs.AddressPickerDialog");
- const validAddressTypes = ['mx-user-id', 'email'];
-
Modal.createTrackedDialog('Start a chat', '', AddressPickerDialog, {
title: _t('Start a chat'),
description: _t("Who would you like to communicate with?"),
@@ -56,7 +54,7 @@ export function showStartChatInviteDialog() {
}
return _t("Name or Matrix ID");
},
- validAddressTypes,
+ validAddressTypes: ['mx-user-id', 'email'],
button: _t("Start Chat"),
onFinished: _onStartDmFinished,
});
@@ -65,11 +63,6 @@ export function showStartChatInviteDialog() {
export function showRoomInviteDialog(roomId) {
const AddressPickerDialog = sdk.getComponent("dialogs.AddressPickerDialog");
- const validAddressTypes = ['mx-user-id'];
- if (MatrixClientPeg.get().getIdentityServerUrl()) {
- validAddressTypes.push('email');
- }
-
Modal.createTrackedDialog('Chat Invite', '', AddressPickerDialog, {
title: _t('Invite new room members'),
button: _t('Send Invites'),
@@ -81,7 +74,7 @@ export function showRoomInviteDialog(roomId) {
}
return _t("Name or Matrix ID");
},
- validAddressTypes,
+ validAddressTypes: ['mx-user-id', 'email'],
onFinished: (shouldInvite, addrs) => {
_onRoomInviteFinished(roomId, shouldInvite, addrs);
},