From 0d996633f201b2ab95d8b9dc376a7da2dcca315d Mon Sep 17 00:00:00 2001 From: Vendicated Date: Fri, 14 Oct 2022 22:38:49 +0200 Subject: ViewIcons: Use ImageModal again --- src/plugins/viewIcons.tsx | 16 ++++++++++------ src/utils/modal.tsx | 7 +++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/plugins/viewIcons.tsx b/src/plugins/viewIcons.tsx index 2b404f2..a55b8b8 100644 --- a/src/plugins/viewIcons.tsx +++ b/src/plugins/viewIcons.tsx @@ -1,6 +1,12 @@ import { Devs } from "../utils/constants"; -import IpcEvents from "../utils/IpcEvents"; import definePlugin from "../utils/types"; +import { lazyWebpack, makeLazy } from "../utils/misc"; +import { ModalSize, openModal } from "../utils/modal"; +import { find } from "../webpack"; +import { React } from "../webpack/common"; + +const ImageModal = lazyWebpack(m => m.prototype?.render?.toString().includes("OPEN_ORIGINAL_IMAGE")); +const getMaskedLink = makeLazy(() => find(m => m.type?.toString().includes("MASKED_LINK)"))); const OPEN_URL = "Vencord.Plugins.plugins.ViewIcons.openImage("; export default definePlugin({ @@ -9,16 +15,14 @@ export default definePlugin({ description: "Makes Avatars/Banners in user profiles clickable, and adds Guild Context Menu Entries to View Banner/Icon.", openImage(url: string) { - VencordNative.ipc.invoke(IpcEvents.OPEN_EXTERNAL, url); - // husk - /* openModal(() => ( + openModal(() => ( React.createElement(getMaskedLink(), props)} /> - ), { size: Modal.ModalSize.DYNAMIC }); */ + ), { size: ModalSize.DYNAMIC }); }, patches: [ diff --git a/src/utils/modal.tsx b/src/utils/modal.tsx index 9e5785d..f142aee 100644 --- a/src/utils/modal.tsx +++ b/src/utils/modal.tsx @@ -10,6 +10,13 @@ const Modals = mapMangledModuleLazy("onCloseRequest:null!=", { let modalId = 1337; +export enum ModalSize { + SMALL = "small", + MEDIUM = "medium", + LARGE = "large", + DYNAMIC = "dynamic", +} + /** * Open a modal * @param Component The component to render in the modal -- cgit