Update type and usage of window.matrixChat to be better React 18 friendly (#28415)
* Update type and usage of window.matrixChat to be better React 18 friendly Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Improve coverage Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Make modules import async to make the file testable Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
349c9b0c26
commit
ca239fee4d
@@ -23,9 +23,6 @@ import ElectronPlatform from "./platform/ElectronPlatform";
|
||||
import PWAPlatform from "./platform/PWAPlatform";
|
||||
import WebPlatform from "./platform/WebPlatform";
|
||||
import { initRageshake, initRageshakeStore } from "./rageshakesetup";
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore - this path is created at runtime and therefore won't exist at typecheck time
|
||||
import { INSTALLED_MODULES } from "../modules";
|
||||
|
||||
export const rageshakePromise = initRageshake();
|
||||
|
||||
@@ -104,7 +101,7 @@ export async function showError(title: string, messages?: string[]): Promise<voi
|
||||
/* webpackChunkName: "error-view" */
|
||||
"../async-components/structures/ErrorView"
|
||||
);
|
||||
window.matrixChat = ReactDOM.render(
|
||||
ReactDOM.render(
|
||||
<StrictMode>
|
||||
<ErrorView title={title} messages={messages} />
|
||||
</StrictMode>,
|
||||
@@ -117,7 +114,7 @@ export async function showIncompatibleBrowser(onAccept: () => void): Promise<voi
|
||||
/* webpackChunkName: "error-view" */
|
||||
"../async-components/structures/ErrorView"
|
||||
);
|
||||
window.matrixChat = ReactDOM.render(
|
||||
ReactDOM.render(
|
||||
<StrictMode>
|
||||
<UnsupportedBrowserView onAccept={onAccept} />
|
||||
</StrictMode>,
|
||||
@@ -126,6 +123,9 @@ export async function showIncompatibleBrowser(onAccept: () => void): Promise<voi
|
||||
}
|
||||
|
||||
export async function loadModules(): Promise<void> {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore - this path is created at runtime and therefore won't exist at typecheck time
|
||||
const { INSTALLED_MODULES } = await import("../modules");
|
||||
for (const InstalledModule of INSTALLED_MODULES) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore - we know the constructor exists even if TypeScript can't be convinced of that
|
||||
|
||||
@@ -11,7 +11,6 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { QueryDict } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import MatrixChatType from "../components/structures/MatrixChat";
|
||||
import { parseQsFromFragment } from "./url_utils";
|
||||
|
||||
let lastLocationHashSet: string | null = null;
|
||||
@@ -31,7 +30,7 @@ function routeUrl(location: Location): void {
|
||||
|
||||
logger.log("Routing URL ", location.href);
|
||||
const s = getScreenFromLocation(location);
|
||||
(window.matrixChat as MatrixChatType).showScreen(s.screen, s.params);
|
||||
window.matrixChat.showScreen(s.screen, s.params);
|
||||
}
|
||||
|
||||
function onHashChange(): void {
|
||||
|
||||
Reference in New Issue
Block a user