- Use proper openJoinAlias
- Avoid requests to join the just joined room
This commit is contained in:
parent
48dcfb0aa9
commit
473d97312e
1 changed files with 69 additions and 77 deletions
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in a new issue