aboutsummaryrefslogtreecommitdiff
path: root/src/utils/modal.tsx
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-10-14 21:34:35 +0200
committerVendicated <vendicated@riseup.net>2022-10-14 21:34:35 +0200
commit296336535f6d23c586c7e83edf0420b58cbf011a (patch)
treeaa2a12bd071b36d44f43da992aa9fddfdd11bf50 /src/utils/modal.tsx
parent563f2fb1dc2067345e4fbd71ce8da7d60d2928e1 (diff)
downloadVencord-296336535f6d23c586c7e83edf0420b58cbf011a.tar.gz
Vencord-296336535f6d23c586c7e83edf0420b58cbf011a.tar.bz2
Vencord-296336535f6d23c586c7e83edf0420b58cbf011a.zip
Fix modals, add wp.mapMangledModule
Diffstat (limited to 'src/utils/modal.tsx')
-rw-r--r--src/utils/modal.tsx25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/utils/modal.tsx b/src/utils/modal.tsx
index b8e647c..9e5785d 100644
--- a/src/utils/modal.tsx
+++ b/src/utils/modal.tsx
@@ -1,13 +1,12 @@
-// TODO: fix
+import { filters } from "../webpack";
+import { lazyWebpack } from "./misc";
+import { mapMangledModuleLazy } from "../webpack/webpack";
-import Components from "discord-types/components";
-import { waitFor } from "../webpack";
-
-export let Modal: Components.Modal;
-export let modals: any;
-
-waitFor("openModalLazy", m => modals = m);
-waitFor("ModalRoot", m => Modal = m);
+const ModalRoot = lazyWebpack(filters.byCode("headerIdIsManaged:"));
+const Modals = mapMangledModuleLazy("onCloseRequest:null!=", {
+ openModal: filters.byCode("onCloseRequest:null!="),
+ closeModal: filters.byCode("onCloseCallback&&")
+});
let modalId = 1337;
@@ -18,10 +17,10 @@ let modalId = 1337;
*/
export function openModal(Component: React.ComponentType, modalProps: Record<string, any>) {
let key = `Vencord${modalId++}`;
- modals.openModal(props => (
- <Modal.ModalRoot {...props} {...modalProps}>
+ Modals.openModal(props => (
+ <ModalRoot {...props} {...modalProps}>
<Component />
- </Modal.ModalRoot>
+ </ModalRoot>
), { modalKey: key });
return key;
@@ -32,5 +31,5 @@ export function openModal(Component: React.ComponentType, modalProps: Record<str
* @param key The key of the modal to close
*/
export function closeModal(key: string) {
- modals.closeModal(key);
+ Modals.closeModal(key);
}