Make invite work without an IS

Also fix it so you can't try to invite a room ID to a room
pull/21833/head
David Baker 2019-08-07 11:41:00 +01:00
parent 366f7e277a
commit bcf53c6e33
2 changed files with 18 additions and 3 deletions

View File

@ -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));

View File

@ -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);
},