mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-08 22:23:02 -04:00
Fix everything broken by recent Discord update (#3177)
Co-authored-by: sadan <117494111+sadan4@users.noreply.github.com> Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
parent
cdc756193e
commit
33d4f13a24
41 changed files with 389 additions and 244 deletions
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { findByPropsLazy, findModuleId, proxyLazyWebpack, wreq } from "@webpack";
|
||||
import { filters, findModuleId, mapMangledModuleLazy, proxyLazyWebpack, wreq } from "@webpack";
|
||||
import type { ComponentType, PropsWithChildren, ReactNode, Ref } from "react";
|
||||
|
||||
import { LazyComponent } from "./react";
|
||||
|
@ -49,7 +49,7 @@ export interface ModalOptions {
|
|||
|
||||
type RenderFunction = (props: ModalProps) => ReactNode | Promise<ReactNode>;
|
||||
|
||||
export const Modals = findByPropsLazy("ModalRoot", "ModalCloseButton") as {
|
||||
interface Modals {
|
||||
ModalRoot: ComponentType<PropsWithChildren<{
|
||||
transitionState: ModalTransitionState;
|
||||
size?: ModalSize;
|
||||
|
@ -99,7 +99,21 @@ export const Modals = findByPropsLazy("ModalRoot", "ModalCloseButton") as {
|
|||
hideOnFullscreen?: boolean;
|
||||
className?: string;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
||||
const Modals: Modals = mapMangledModuleLazy(':"thin")', {
|
||||
ModalRoot: filters.componentByCode('.MODAL,"aria-labelledby":'),
|
||||
ModalHeader: filters.componentByCode(",id:"),
|
||||
ModalContent: filters.componentByCode(".content,"),
|
||||
ModalFooter: filters.componentByCode(".footer,"),
|
||||
ModalCloseButton: filters.componentByCode(".close]:")
|
||||
});
|
||||
|
||||
export const ModalRoot = LazyComponent(() => Modals.ModalRoot);
|
||||
export const ModalHeader = LazyComponent(() => Modals.ModalHeader);
|
||||
export const ModalContent = LazyComponent(() => Modals.ModalContent);
|
||||
export const ModalFooter = LazyComponent(() => Modals.ModalFooter);
|
||||
export const ModalCloseButton = LazyComponent(() => Modals.ModalCloseButton);
|
||||
|
||||
export type MediaModalItem = {
|
||||
url: string;
|
||||
|
@ -135,38 +149,33 @@ export const openMediaModal: (props: MediaModalProps) => void = proxyLazyWebpack
|
|||
return Object.values<any>(openMediaModalModule).find(v => String(v).includes("modalKey:"));
|
||||
});
|
||||
|
||||
export const ModalRoot = LazyComponent(() => Modals.ModalRoot);
|
||||
export const ModalHeader = LazyComponent(() => Modals.ModalHeader);
|
||||
export const ModalContent = LazyComponent(() => Modals.ModalContent);
|
||||
export const ModalFooter = LazyComponent(() => Modals.ModalFooter);
|
||||
export const ModalCloseButton = LazyComponent(() => Modals.ModalCloseButton);
|
||||
interface ModalAPI {
|
||||
/**
|
||||
* Wait for the render promise to resolve, then open a modal with it.
|
||||
* This is equivalent to render().then(openModal)
|
||||
* You should use the Modal components exported by this file
|
||||
*/
|
||||
openModalLazy: (render: () => Promise<RenderFunction>, options?: ModalOptions & { contextKey?: string; }) => Promise<string>;
|
||||
/**
|
||||
* Open a Modal with the given render function.
|
||||
* You should use the Modal components exported by this file
|
||||
*/
|
||||
openModal: (render: RenderFunction, options?: ModalOptions, contextKey?: string) => string;
|
||||
/**
|
||||
* Close a modal by its key
|
||||
*/
|
||||
closeModal: (modalKey: string, contextKey?: string) => void;
|
||||
/**
|
||||
* Close all open modals
|
||||
*/
|
||||
closeAllModals: () => void;
|
||||
}
|
||||
|
||||
export const ModalAPI = findByPropsLazy("openModalLazy");
|
||||
|
||||
/**
|
||||
* Wait for the render promise to resolve, then open a modal with it.
|
||||
* This is equivalent to render().then(openModal)
|
||||
* You should use the Modal components exported by this file
|
||||
*/
|
||||
export const openModalLazy: (render: () => Promise<RenderFunction>, options?: ModalOptions & { contextKey?: string; }) => Promise<string>
|
||||
= proxyLazyWebpack(() => ModalAPI.openModalLazy);
|
||||
|
||||
/**
|
||||
* Open a Modal with the given render function.
|
||||
* You should use the Modal components exported by this file
|
||||
*/
|
||||
export const openModal: (render: RenderFunction, options?: ModalOptions, contextKey?: string) => string
|
||||
= proxyLazyWebpack(() => ModalAPI.openModal);
|
||||
|
||||
/**
|
||||
* Close a modal by its key
|
||||
*/
|
||||
export const closeModal: (modalKey: string, contextKey?: string) => void
|
||||
= proxyLazyWebpack(() => ModalAPI.closeModal);
|
||||
|
||||
/**
|
||||
* Close all open modals
|
||||
*/
|
||||
export const closeAllModals: () => void
|
||||
= proxyLazyWebpack(() => ModalAPI.closeAllModals);
|
||||
export const ModalAPI: ModalAPI = mapMangledModuleLazy(".modalKey?", {
|
||||
openModalLazy: filters.byCode(".modalKey?"),
|
||||
openModal: filters.byCode(",instant:"),
|
||||
closeModal: filters.byCode(".onCloseCallback()"),
|
||||
closeAllModals: filters.byCode(".getState();for")
|
||||
});
|
||||
|
||||
export const { openModalLazy, openModal, closeModal, closeAllModals } = ModalAPI;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue