Fix plugins using ImageModals (again)

This commit is contained in:
Nuckyz 2024-10-24 08:10:29 -03:00
parent 534ab3eb5f
commit f5f59be1b6
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
3 changed files with 46 additions and 34 deletions

View file

@ -21,8 +21,9 @@ import "./discord.css";
import { MessageObject } from "@api/MessageEvents";
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, InviteActions, MessageActions, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
import { Channel, Guild, Message, User } from "discord-types/general";
import { Except } from "type-fest";
import { ImageModal, ImageModalItem, openModal } from "./modal";
import { MediaModalItem, MediaModalProps, openMediaModal } from "./modal";
/**
* Open the invite modal
@ -111,24 +112,20 @@ export function sendMessage(
}
/**
* You must specify either height or width
* You must specify either height or width in the item
*/
export function openImageModal(props: Omit<ImageModalItem, "type">): string {
return openModal(modalProps => (
<ImageModal
{...modalProps}
className="vc-image-modal"
fit="vc-position-inherit"
items={[{
type: "IMAGE",
original: props.url,
...props,
}]}
onClose={modalProps.onClose}
shouldHideMediaOptions={false}
shouldAnimate
/>
));
export function openImageModal(item: Except<MediaModalItem, "type">, mediaModalProps?: Omit<MediaModalProps, "items">) {
return openMediaModal({
className: "vc-image-modal",
fit: "vc-position-inherit",
shouldAnimateCarousel: true,
items: [{
type: "IMAGE",
original: item.original ?? item.url,
...item,
}],
...mediaModalProps
});
}
export async function openUserProfile(id: string) {