mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-03-13 06:30:01 +01:00
* support room via server params and eventId * change copy link to matrix.to links * display matrix.to links in messages as pill and stop generating url previews for them * improve editor mention to include viaServers and eventId * fix mention custom attributes * always try to open room in current space * jump to latest remove target eventId from url * add create direct search options to open/create dm with url
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import React, { ReactNode } from 'react';
|
|
import { useParams } from 'react-router-dom';
|
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
|
import { useSpaces } from '../../../state/hooks/roomList';
|
|
import { allRoomsAtom } from '../../../state/room-list/roomList';
|
|
import { useSelectedSpace } from '../../../hooks/router/useSelectedSpace';
|
|
import { SpaceProvider } from '../../../hooks/useSpace';
|
|
import { JoinBeforeNavigate } from '../../../features/join-before-navigate';
|
|
import { useSearchParamsViaServers } from '../../../hooks/router/useSearchParamsViaServers';
|
|
|
|
type RouteSpaceProviderProps = {
|
|
children: ReactNode;
|
|
};
|
|
export function RouteSpaceProvider({ children }: RouteSpaceProviderProps) {
|
|
const mx = useMatrixClient();
|
|
const joinedSpaces = useSpaces(mx, allRoomsAtom);
|
|
|
|
const { spaceIdOrAlias } = useParams();
|
|
const viaServers = useSearchParamsViaServers();
|
|
|
|
const selectedSpaceId = useSelectedSpace();
|
|
const space = mx.getRoom(selectedSpaceId);
|
|
|
|
if (!space || !joinedSpaces.includes(space.roomId)) {
|
|
return <JoinBeforeNavigate roomIdOrAlias={spaceIdOrAlias ?? ''} viaServers={viaServers} />;
|
|
}
|
|
|
|
return (
|
|
<SpaceProvider key={space.roomId} value={space}>
|
|
{children}
|
|
</SpaceProvider>
|
|
);
|
|
}
|