mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-05 20:26:19 +02:00
Fairly awful workaround
to actually break the dependency nightmare
This commit is contained in:
parent
2dd743dea0
commit
738eac9b90
@ -7,10 +7,27 @@ Please see LICENSE files in the repository root for full details.
|
||||
|
||||
import { type RoomViewProps, type BuiltinsApi } from "@element-hq/element-web-module-api";
|
||||
|
||||
import { RoomView } from "../components/structures/RoomView";
|
||||
|
||||
export class ElementWebBuiltinsApi implements BuiltinsApi {
|
||||
private _roomView?: React.ComponentType<RoomViewProps>;
|
||||
|
||||
/**
|
||||
* Sets the components used to render a RoomView
|
||||
*
|
||||
* This only really exists here because referencing RoomView directly causes a nightmare of
|
||||
* circular dependencies that break the whole app, so instead we avoid referencing it here
|
||||
* and pass it in from somewhere it's already referenced (see related comment in app.tsx).
|
||||
*
|
||||
* @param component The RoomView component
|
||||
*/
|
||||
public setRoomViewComponent(component: React.ComponentType<RoomViewProps>): void {
|
||||
this._roomView = component;
|
||||
}
|
||||
|
||||
public getRoomViewComponent(): React.ComponentType<RoomViewProps> {
|
||||
return RoomView;
|
||||
if (!this._roomView) {
|
||||
throw new Error("No RoomView component has been set");
|
||||
}
|
||||
|
||||
return this._roomView;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,8 @@ import { ModuleRunner } from "../modules/ModuleRunner";
|
||||
import { parseQs } from "./url_utils";
|
||||
import { getInitialScreenAfterLogin, getScreenFromLocation, init as initRouting, onNewScreen } from "./routing";
|
||||
import { UserFriendlyError } from "../languageHandler";
|
||||
import { ModuleApi } from "../modules/Api";
|
||||
import { RoomView } from "../components/structures/RoomView";
|
||||
|
||||
logger.log(`Application is running in ${process.env.NODE_ENV} mode`);
|
||||
|
||||
@ -53,6 +55,11 @@ function onTokenLoginCompleted(): void {
|
||||
}
|
||||
|
||||
export async function loadApp(fragParams: QueryDict, matrixChatRef: React.Ref<MatrixChat>): Promise<ReactElement> {
|
||||
// XXX: This lives here because RoomVew import so many things that importing it in a sensible place (eg.
|
||||
// the builtins module or init.tsx) causes a circular dependency. Instead, we reference RoomView here where we
|
||||
// already reference it indirectly via MatrixChat.
|
||||
ModuleApi.instance.builtins.setRoomViewComponent(RoomView);
|
||||
|
||||
initRouting();
|
||||
const platform = PlatformPeg.get();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user