- Use proper openJoinAlias

- Avoid requests to join the just joined room
This commit is contained in:
C0ffeeCode 2022-05-12 10:37:17 +02:00
parent 48dcfb0aa9
commit 473d97312e
No known key found for this signature in database
GPG key ID: 211B3EF9F31E56FE

View file

@ -1,20 +1,12 @@
import {
selectRoom, selectSpace,
selectRoom, selectSpace, openJoinAlias,
} from '../client/action/navigation';
import matrixClient from '../client/initMatrix';
import navigation from '../client/state/navigation';
import cons from '../client/state/cons';
async function joinRoom(roomAlias) {
const room = await matrixClient.matrixClient.getRoomSummary(roomAlias);
// TODO: Check if already joined, replace this confirm
if (!confirm(`Do you want to join ${room.name} (${roomAlias})?`)) return;
await matrixClient.matrixClient.joinRoom(roomAlias);
const state = await matrixClient.matrixClient.roomState(room.room_id);
const isSpace = state.find((e) => e.type === 'm.room.create').content.type === 'm.space';
if (isSpace) selectSpace(room.room_id);
else selectRoom(room.room_id);
openJoinAlias(roomAlias);
}
const listeners = [];
@ -59,6 +51,7 @@ import {
else a[3] = eventId;
if (!selectRoom) a.length = 2;
else a[2] = selectedRoom;
if (a[1] === 'join') a[1] = cons.tabs.HOME;
window.location.hash = a.join('/');
}),
@ -78,4 +71,3 @@ import {
export function destructUrlHandling() {
listeners.forEach((l) => navigation.removeListener(l));
}