Change module API to be an instance getter (#31025)

* Change module API to be an instance getter

Helps with circular dependencies by not instantating the module API
on the initial evaluation of the files.

* Add basic test

* add another test
This commit is contained in:
David Baker
2025-10-15 09:20:48 +00:00
committed by GitHub
parent 6cfe197a38
commit 146e4772ac
8 changed files with 82 additions and 23 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ import { _t } from "../languageHandler";
import Modal from "../Modal";
import { FileDownloader } from "../utils/FileDownloader";
import { MediaEventHelper } from "../utils/MediaEventHelper";
import ModuleApi from "../modules/Api";
import { ModuleApi } from "../modules/Api";
export interface UseDownloadMediaReturn {
download: () => Promise<void>;
@@ -34,7 +34,7 @@ export function useDownloadMedia(url: string, fileName?: string, mxEvent?: Matri
useEffect(() => {
if (!mxEvent) return;
const hints = ModuleApi.customComponents.getHintsForMessage(mxEvent);
const hints = ModuleApi.instance.customComponents.getHintsForMessage(mxEvent);
if (hints?.allowDownloadingMedia) {
setCanDownload(false);
hints