mirror of
https://github.com/element-hq/element-web
synced 2024-11-21 16:55:34 +03:00
Correctly fill window.matrixChat even when a Wrapper module is active (#26395)
Signed-off-by: Dominik Henneke <dominik.henneke@nordeck.net>
This commit is contained in:
parent
f1a39b3e4d
commit
0040181489
4 changed files with 16 additions and 6 deletions
|
@ -65,7 +65,7 @@ function onTokenLoginCompleted(): void {
|
|||
window.history.replaceState(null, "", url.href);
|
||||
}
|
||||
|
||||
export async function loadApp(fragParams: {}): Promise<ReactElement> {
|
||||
export async function loadApp(fragParams: {}, matrixChatRef: React.Ref<MatrixChat>): Promise<ReactElement> {
|
||||
initRouting();
|
||||
const platform = PlatformPeg.get();
|
||||
|
||||
|
@ -117,6 +117,7 @@ export async function loadApp(fragParams: {}): Promise<ReactElement> {
|
|||
return (
|
||||
<wrapperOpts.Wrapper>
|
||||
<MatrixChat
|
||||
ref={matrixChatRef}
|
||||
onNewScreen={onNewScreen}
|
||||
config={config}
|
||||
realQueryParams={params}
|
||||
|
|
|
@ -30,6 +30,7 @@ import SdkConfig from "matrix-react-sdk/src/SdkConfig";
|
|||
import { setTheme } from "matrix-react-sdk/src/theme";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { ModuleRunner } from "matrix-react-sdk/src/modules/ModuleRunner";
|
||||
import MatrixChat from "matrix-react-sdk/src/components/structures/MatrixChat";
|
||||
|
||||
import ElectronPlatform from "./platform/ElectronPlatform";
|
||||
import PWAPlatform from "./platform/PWAPlatform";
|
||||
|
@ -147,7 +148,10 @@ export async function loadApp(fragParams: {}): Promise<void> {
|
|||
/* webpackPreload: true */
|
||||
"./app"
|
||||
);
|
||||
window.matrixChat = ReactDOM.render(await module.loadApp(fragParams), document.getElementById("matrixchat"));
|
||||
function setWindowMatrixChat(matrixChat: MatrixChat): void {
|
||||
window.matrixChat = matrixChat;
|
||||
}
|
||||
ReactDOM.render(await module.loadApp(fragParams, setWindowMatrixChat), document.getElementById("matrixchat"));
|
||||
}
|
||||
|
||||
export async function showError(title: string, messages?: string[]): Promise<void> {
|
||||
|
|
|
@ -47,7 +47,7 @@ describe("Loading server config", function () {
|
|||
},
|
||||
},
|
||||
});
|
||||
await loadApp({});
|
||||
await loadApp({}, null);
|
||||
expect((SdkConfig.get("validated_server_config") || {}).hsUrl).toBe("https://matrix-client.matrix.org");
|
||||
});
|
||||
|
||||
|
@ -55,7 +55,7 @@ describe("Loading server config", function () {
|
|||
SdkConfig.put({
|
||||
default_server_name: "matrix.org",
|
||||
});
|
||||
await loadApp({});
|
||||
await loadApp({}, null);
|
||||
expect((SdkConfig.get("validated_server_config") || {}).hsUrl).toBe("https://matrix-client.matrix.org");
|
||||
});
|
||||
|
||||
|
@ -72,7 +72,7 @@ describe("Loading server config", function () {
|
|||
},
|
||||
},
|
||||
});
|
||||
await loadApp({});
|
||||
await loadApp({}, null);
|
||||
expect((SdkConfig.get("validated_server_config") || {}).hsUrl).toBe("https://matrix-client.matrix.org");
|
||||
},
|
||||
);
|
||||
|
|
|
@ -22,6 +22,7 @@ import fetchMock from "fetch-mock-jest";
|
|||
import { render, RenderResult, screen } from "@testing-library/react";
|
||||
import { ModuleRunner } from "matrix-react-sdk/src/modules/ModuleRunner";
|
||||
import { WrapperLifecycle, WrapperOpts } from "@matrix-org/react-sdk-module-api/lib/lifecycles/WrapperLifecycle";
|
||||
import MatrixChat from "matrix-react-sdk/src/components/structures/MatrixChat";
|
||||
|
||||
import WebPlatform from "../../src/vector/platform/WebPlatform";
|
||||
import { loadApp } from "../../src/vector/app";
|
||||
|
@ -68,7 +69,8 @@ describe("Wrapper", () => {
|
|||
}
|
||||
});
|
||||
|
||||
const matrixChatResult: RenderResult = render(await loadApp({}));
|
||||
const ref = React.createRef<MatrixChat>();
|
||||
const matrixChatResult: RenderResult = render(await loadApp({}, ref));
|
||||
|
||||
// at this point, we're trying to do a guest registration;
|
||||
// we expect a spinner
|
||||
|
@ -83,5 +85,8 @@ describe("Wrapper", () => {
|
|||
|
||||
expect(header.nextSibling).toBe(matrixChat);
|
||||
expect(matrixChat.nextSibling).toBe(footer);
|
||||
|
||||
// Should still hold a reference to the MatrixChat component
|
||||
expect(ref.current).toBeInstanceOf(MatrixChat);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue