mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-30 05:42:44 -08:00
Centralize Matrix SDK imports behind a local compatibility module, migrate matrix subpath imports to the boundary, and switch to the $types alias. Upgrade TypeScript to latest so matrix-js-sdk typings resolve correctly before the next cleanup phase.
13 lines
412 B
TypeScript
13 lines
412 B
TypeScript
import { createContext, useContext } from 'react';
|
|
import { MatrixClient } from '$types/matrix-sdk';
|
|
|
|
const MatrixClientContext = createContext<MatrixClient | null>(null);
|
|
|
|
export const MatrixClientProvider = MatrixClientContext.Provider;
|
|
|
|
export function useMatrixClient(): MatrixClient {
|
|
const mx = useContext(MatrixClientContext);
|
|
if (!mx) throw new Error('MatrixClient not initialized!');
|
|
return mx;
|
|
}
|