From bcf53c6e335a376bf963104ea0feeb050a7a6129 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 7 Aug 2019 11:41:00 +0100 Subject: [PATCH] Make invite work without an IS Also fix it so you can't try to invite a room ID to a room --- src/Lifecycle.js | 6 ++++-- src/RoomInvite.js | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index cad876e019..0ddb7e9aae 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -251,7 +251,7 @@ function _registerAsGuest(hsUrl, isUrl, defaultDeviceDisplayName) { */ export function getLocalStorageSessionVars() { const hsUrl = localStorage.getItem("mx_hs_url"); - const isUrl = localStorage.getItem("mx_is_url") || 'https://matrix.org'; + const isUrl = localStorage.getItem("mx_is_url"); const accessToken = localStorage.getItem("mx_access_token"); const userId = localStorage.getItem("mx_user_id"); const deviceId = localStorage.getItem("mx_device_id"); @@ -479,7 +479,9 @@ class AbortLoginAndRebuildStorage extends Error { } function _persistCredentialsToLocalStorage(credentials) { localStorage.setItem("mx_hs_url", credentials.homeserverUrl); - localStorage.setItem("mx_is_url", credentials.identityServerUrl); + if (credentials.identityServerUrl) { + localStorage.setItem("mx_is_url", credentials.identityServerUrl); + } localStorage.setItem("mx_user_id", credentials.userId); localStorage.setItem("mx_access_token", credentials.accessToken); localStorage.setItem("mx_is_guest", JSON.stringify(credentials.guest)); diff --git a/src/RoomInvite.js b/src/RoomInvite.js index 34b9635780..cfea51100b 100644 --- a/src/RoomInvite.js +++ b/src/RoomInvite.js @@ -42,11 +42,17 @@ 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'); + } + Modal.createTrackedDialog('Start a chat', '', AddressPickerDialog, { title: _t('Start a chat'), description: _t("Who would you like to communicate with?"), placeholder: _t("Email, name or Matrix ID"), - validAddressTypes: ['mx-user-id', 'email'], + validAddressTypes, button: _t("Start Chat"), onFinished: _onStartChatFinished, }); @@ -54,11 +60,18 @@ 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'), description: _t('Who would you like to add to this room?'), button: _t('Send Invites'), placeholder: _t("Email, name or Matrix ID"), + validAddressTypes, onFinished: (shouldInvite, addrs) => { _onRoomInviteFinished(roomId, shouldInvite, addrs); },