Allow creating a room with only yourself in it

Fixes https://github.com/vector-im/riot-web/issues/12092
pull/21833/head
Travis Ralston 2020-02-20 23:16:21 -07:00
parent f491e4222a
commit 8ba274a382
1 changed files with 7 additions and 3 deletions

View File

@ -513,7 +513,8 @@ export default class InviteDialog extends React.PureComponent {
}
_convertFilter(): Member[] {
if (!this.state.filterText || !this.state.filterText.includes('@')) return; // nothing to convert
// Check to see if there's anything to convert first
if (!this.state.filterText || !this.state.filterText.includes('@')) return this.state.targets || [];
let newMember: Member;
if (this.state.filterText.startsWith('@')) {
@ -523,7 +524,7 @@ export default class InviteDialog extends React.PureComponent {
// Assume email
newMember = new ThreepidMember(this.state.filterText);
}
const newTargets = [...this.state.targets, newMember];
const newTargets = [...(this.state.targets || []), newMember];
this.setState({targets: newTargets, filterText: ''});
return newTargets;
}
@ -561,9 +562,12 @@ export default class InviteDialog extends React.PureComponent {
// Check if it's a traditional DM and create the room if required.
// TODO: [Canonical DMs] Remove this check and instead just create the multi-person DM
let createRoomPromise = Promise.resolve();
if (targetIds.length === 1) {
const isSelf = targetIds.length === 1 && targetIds[0] === MatrixClientPeg.get().getUserId();
if (targetIds.length === 1 && !isSelf) {
createRoomOptions.dmUserId = targetIds[0];
createRoomPromise = createRoom(createRoomOptions);
} else if (isSelf) {
createRoomPromise = createRoom(createRoomOptions);
} else {
// Create a boring room and try to invite the targets manually.
createRoomPromise = createRoom(createRoomOptions).then(roomId => {