1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-09 09:26:22 +00:00

ConsoleShortcuts: Add openModal and openModalLazy (#3118)

This commit is contained in:
sadan4 2025-01-04 00:01:58 -05:00 committed by GitHub
parent 34629307dd
commit 3af06edb95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 13 deletions

View file

@ -20,6 +20,7 @@ import { Devs } from "@utils/constants";
import { getCurrentChannel, getCurrentGuild } from "@utils/discord"; import { getCurrentChannel, getCurrentGuild } from "@utils/discord";
import { runtimeHashMessageKey } from "@utils/intlHash"; import { runtimeHashMessageKey } from "@utils/intlHash";
import { SYM_LAZY_CACHED, SYM_LAZY_GET } from "@utils/lazy"; import { SYM_LAZY_CACHED, SYM_LAZY_GET } from "@utils/lazy";
import { ModalAPI } from "@utils/modal";
import { relaunch } from "@utils/native"; import { relaunch } from "@utils/native";
import { canonicalizeMatch, canonicalizeReplace, canonicalizeReplacement } from "@utils/patches"; import { canonicalizeMatch, canonicalizeReplace, canonicalizeReplacement } from "@utils/patches";
import definePlugin, { PluginNative, StartAt } from "@utils/types"; import definePlugin, { PluginNative, StartAt } from "@utils/types";
@ -144,6 +145,8 @@ function makeShortcuts() {
me: { getter: () => Common.UserStore.getCurrentUser(), preload: false }, me: { getter: () => Common.UserStore.getCurrentUser(), preload: false },
meId: { getter: () => Common.UserStore.getCurrentUser().id, preload: false }, meId: { getter: () => Common.UserStore.getCurrentUser().id, preload: false },
messages: { getter: () => Common.MessageStore.getMessages(Common.SelectedChannelStore.getChannelId()), preload: false }, messages: { getter: () => Common.MessageStore.getMessages(Common.SelectedChannelStore.getChannelId()), preload: false },
openModal: { getter: () => ModalAPI.openModal },
openModalLazy: { getter: () => ModalAPI.openModalLazy },
Stores: { Stores: {
getter: () => Object.fromEntries( getter: () => Object.fromEntries(

View file

@ -141,35 +141,32 @@ export const ModalContent = LazyComponent(() => Modals.ModalContent);
export const ModalFooter = LazyComponent(() => Modals.ModalFooter); export const ModalFooter = LazyComponent(() => Modals.ModalFooter);
export const ModalCloseButton = LazyComponent(() => Modals.ModalCloseButton); export const ModalCloseButton = LazyComponent(() => Modals.ModalCloseButton);
const ModalAPI = findByPropsLazy("openModalLazy"); export const ModalAPI = findByPropsLazy("openModalLazy");
/** /**
* Wait for the render promise to resolve, then open a modal with it. * Wait for the render promise to resolve, then open a modal with it.
* This is equivalent to render().then(openModal) * This is equivalent to render().then(openModal)
* You should use the Modal components exported by this file * You should use the Modal components exported by this file
*/ */
export function openModalLazy(render: () => Promise<RenderFunction>, options?: ModalOptions & { contextKey?: string; }): Promise<string> { export const openModalLazy: (render: () => Promise<RenderFunction>, options?: ModalOptions & { contextKey?: string; }) => Promise<string>
return ModalAPI.openModalLazy(render, options); = proxyLazyWebpack(() => ModalAPI.openModalLazy);
}
/** /**
* Open a Modal with the given render function. * Open a Modal with the given render function.
* You should use the Modal components exported by this file * You should use the Modal components exported by this file
*/ */
export function openModal(render: RenderFunction, options?: ModalOptions, contextKey?: string): string { export const openModal: (render: RenderFunction, options?: ModalOptions, contextKey?: string) => string
return ModalAPI.openModal(render, options, contextKey); = proxyLazyWebpack(() => ModalAPI.openModal);
}
/** /**
* Close a modal by its key * Close a modal by its key
*/ */
export function closeModal(modalKey: string, contextKey?: string): void { export const closeModal: (modalKey: string, contextKey?: string) => void
return ModalAPI.closeModal(modalKey, contextKey); = proxyLazyWebpack(() => ModalAPI.closeModal);
}
/** /**
* Close all open modals * Close all open modals
*/ */
export function closeAllModals(): void { export const closeAllModals: () => void
return ModalAPI.closeAllModals(); = proxyLazyWebpack(() => ModalAPI.closeAllModals);
}