Separate out SDKContext (#34053)
* Separate out SDKContext ...from SDKContextClass, as the comments hopefully explain. Also make the captitalisation consistent. * Adding the new file usually helps too * Fix import * More comment * Update the various imports of SDKContextClass * Also fix case of TestSDKContext * Update the mock
This commit is contained in:
@@ -14,7 +14,7 @@ import { MainSplitContentType } from "../../src/contexts/RoomContext";
|
||||
import { type RoomContextType, TimelineRenderingType } from "../../src/contexts/RoomContext";
|
||||
import { Layout } from "../../src/settings/enums/Layout";
|
||||
import { mkEvent } from "./test-utils";
|
||||
import { SdkContextClass } from "../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../src/contexts/SDKContextClass";
|
||||
|
||||
export const makeMembershipEvent = (roomId: string, userId: string, membership = KnownMembership.Join) =>
|
||||
mkEvent({
|
||||
@@ -45,7 +45,7 @@ export const makeRoomWithStateEvents = (
|
||||
|
||||
export function getRoomContext(room: Room, override: Partial<RoomContextType>): RoomContextType {
|
||||
return {
|
||||
roomViewStore: SdkContextClass.instance.roomViewStore,
|
||||
roomViewStore: SDKContextClass.instance.roomViewStore,
|
||||
room,
|
||||
roomLoading: true,
|
||||
peekLoading: false,
|
||||
|
||||
@@ -12,7 +12,8 @@ import { type RenderOptions } from "jest-matrix-react";
|
||||
|
||||
import { MatrixClientPeg as peg } from "../../src/MatrixClientPeg";
|
||||
import MatrixClientContext from "../../src/contexts/MatrixClientContext";
|
||||
import { SDKContext, type SdkContextClass } from "../../src/contexts/SDKContext";
|
||||
import { SDKContext } from "../../src/contexts/SDKContext";
|
||||
import { type SDKContextClass } from "../../src/contexts/SDKContextClass";
|
||||
|
||||
type WrapperProps<T> = { wrappedRef?: Ref<ComponentType<T>> } & T;
|
||||
|
||||
@@ -38,7 +39,7 @@ export function wrapInMatrixClientContext<T>(WrappedComponent: ComponentType<T>)
|
||||
|
||||
export function wrapInSdkContext<T>(
|
||||
WrappedComponent: ComponentType<T>,
|
||||
sdkContext: SdkContextClass,
|
||||
sdkContext: SDKContextClass,
|
||||
): ComponentType<WrapperProps<T>> {
|
||||
return class extends React.Component<WrapperProps<T>> {
|
||||
render() {
|
||||
@@ -63,7 +64,7 @@ export function withClientContextRenderOptions(client: MatrixClient): RenderOpti
|
||||
};
|
||||
}
|
||||
|
||||
export function clientAndSDKContextRenderOptions(client: MatrixClient, sdkContext: SdkContextClass): RenderOptions {
|
||||
export function clientAndSDKContextRenderOptions(client: MatrixClient, sdkContext: SDKContextClass): RenderOptions {
|
||||
return {
|
||||
wrapper: ({ children }) => (
|
||||
<SDKContext.Provider value={sdkContext}>
|
||||
|
||||
Reference in New Issue
Block a user