mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-13 08:33:01 -04:00
Fixes
This commit is contained in:
parent
28794c4d53
commit
6fc7fc9f97
8 changed files with 51 additions and 47 deletions
|
@ -8,7 +8,7 @@ import { definePluginSettings } from "@api/Settings";
|
||||||
import { getUserSettingLazy } from "@api/UserSettings";
|
import { getUserSettingLazy } from "@api/UserSettings";
|
||||||
import { ImageIcon } from "@components/Icons";
|
import { ImageIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { getCurrentGuild, openImageModal } from "@utils/discord";
|
import { getCurrentGuild, openMediaModal } from "@utils/discord";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Clipboard, GuildStore, Menu, PermissionStore } from "@webpack/common";
|
import { Clipboard, GuildStore, Menu, PermissionStore } from "@webpack/common";
|
||||||
|
@ -99,7 +99,7 @@ export default definePlugin({
|
||||||
id="vc-view-role-icon"
|
id="vc-view-role-icon"
|
||||||
label="View Role Icon"
|
label="View Role Icon"
|
||||||
action={() => {
|
action={() => {
|
||||||
openImageModal(`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${role.id}/${role.icon}.${settings.store.roleIconFileFormat}`);
|
openMediaModal(`${location.protocol}//${window.GLOBAL_ENV.CDN_HOST}/role-icons/${role.id}/${role.icon}.${settings.store.roleIconFileFormat}`);
|
||||||
}}
|
}}
|
||||||
icon={ImageIcon}
|
icon={ImageIcon}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
import { ScreenshareIcon } from "@components/Icons";
|
import { ScreenshareIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { openImageModal } from "@utils/discord";
|
import { openMediaModal } from "@utils/discord";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { Menu } from "@webpack/common";
|
import { Menu } from "@webpack/common";
|
||||||
import { Channel, User } from "discord-types/general";
|
import { Channel, User } from "discord-types/general";
|
||||||
|
@ -57,7 +57,7 @@ export const handleViewPreview = async ({ guildId, channelId, ownerId }: Applica
|
||||||
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);
|
const previewUrl = await ApplicationStreamPreviewStore.getPreviewURL(guildId, channelId, ownerId);
|
||||||
if (!previewUrl) return;
|
if (!previewUrl) return;
|
||||||
|
|
||||||
openImageModal(previewUrl);
|
openMediaModal(previewUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {
|
export const addViewStreamContext: NavContextMenuPatchCallback = (children, { userId }: { userId: string | bigint; }) => {
|
||||||
|
|
|
@ -156,14 +156,14 @@ export default definePlugin({
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "Messages.OPEN_IN_BROWSER",
|
find: ".contain,SCALE_DOWN:",
|
||||||
replacement: {
|
replacement: {
|
||||||
// there are 2 image thingies. one for carosuel and one for the single image.
|
// there are 2 image thingies. one for carosuel and one for the single image.
|
||||||
// so thats why i added global flag.
|
// so thats why i added global flag.
|
||||||
// also idk if this patch is good, should it be more specific?
|
// also idk if this patch is good, should it be more specific?
|
||||||
// https://regex101.com/r/xfvNvV/1
|
// https://regex101.com/r/xfvNvV/1
|
||||||
match: /return.{1,200}\.wrapper.{1,200}src:\i,/g,
|
match: /\.slide,\i\),/g,
|
||||||
replace: `$&id: '${ELEMENT_ID}',`
|
replace: `$&id:"${ELEMENT_ID}",`
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
|
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { openImageModal, openUserProfile } from "@utils/discord";
|
import { openMediaModal, openUserProfile } from "@utils/discord";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { ModalRoot, ModalSize, openModal } from "@utils/modal";
|
import { ModalRoot, ModalSize, openModal } from "@utils/modal";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
|
@ -80,7 +80,7 @@ function GuildInfoModal({ guild }: GuildProps) {
|
||||||
className={cl("banner")}
|
className={cl("banner")}
|
||||||
src={bannerUrl}
|
src={bannerUrl}
|
||||||
alt=""
|
alt=""
|
||||||
onClick={() => openImageModal(bannerUrl)}
|
onClick={() => openMediaModal(bannerUrl)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ function GuildInfoModal({ guild }: GuildProps) {
|
||||||
? <img
|
? <img
|
||||||
src={iconUrl}
|
src={iconUrl}
|
||||||
alt=""
|
alt=""
|
||||||
onClick={() => openImageModal(iconUrl)}
|
onClick={() => openMediaModal(iconUrl)}
|
||||||
/>
|
/>
|
||||||
: <div aria-hidden className={classes(IconClasses.childWrapper, IconClasses.acronym)}>{guild.acronym}</div>
|
: <div aria-hidden className={classes(IconClasses.childWrapper, IconClasses.acronym)}>{guild.acronym}</div>
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ function Owner(guildId: string, owner: User) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cl("owner")}>
|
<div className={cl("owner")}>
|
||||||
<img src={ownerAvatarUrl} alt="" onClick={() => openImageModal(ownerAvatarUrl)} />
|
<img src={ownerAvatarUrl} alt="" onClick={() => openMediaModal(ownerAvatarUrl)} />
|
||||||
{Parser.parse(`<@${owner.id}>`)}
|
{Parser.parse(`<@${owner.id}>`)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,7 +21,7 @@ import "./spotifyStyles.css";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
|
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
|
||||||
import { debounce } from "@shared/debounce";
|
import { debounce } from "@shared/debounce";
|
||||||
import { openImageModal } from "@utils/discord";
|
import { openMediaModal } from "@utils/discord";
|
||||||
import { classes, copyWithToast } from "@utils/misc";
|
import { classes, copyWithToast } from "@utils/misc";
|
||||||
import { ContextMenuApi, FluxDispatcher, Forms, Menu, React, useEffect, useState, useStateFromStores } from "@webpack/common";
|
import { ContextMenuApi, FluxDispatcher, Forms, Menu, React, useEffect, useState, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ function AlbumContextMenu({ track }: { track: Track; }) {
|
||||||
id="view-cover"
|
id="view-cover"
|
||||||
label="View Album Cover"
|
label="View Album Cover"
|
||||||
// trolley
|
// trolley
|
||||||
action={() => openImageModal(track.album.image.url)}
|
action={() => openMediaModal(track.album.image.url)}
|
||||||
icon={ImageIcon}
|
icon={ImageIcon}
|
||||||
/>
|
/>
|
||||||
<Menu.MenuControlItem
|
<Menu.MenuControlItem
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import { ImageIcon } from "@components/Icons";
|
import { ImageIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { openImageModal } from "@utils/discord";
|
import { openMediaModal } from "@utils/discord";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { GuildMemberStore, IconUtils, Menu } from "@webpack/common";
|
import { GuildMemberStore, IconUtils, Menu } from "@webpack/common";
|
||||||
import type { Channel, Guild, User } from "discord-types/general";
|
import type { Channel, Guild, User } from "discord-types/general";
|
||||||
|
@ -78,9 +78,10 @@ function openImage(url: string) {
|
||||||
u.searchParams.set("size", "4096");
|
u.searchParams.set("size", "4096");
|
||||||
const originalUrl = u.toString();
|
const originalUrl = u.toString();
|
||||||
|
|
||||||
openImageModal(url, {
|
openMediaModal({
|
||||||
|
url,
|
||||||
original: originalUrl,
|
original: originalUrl,
|
||||||
height: 256
|
maxHeight: 256
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { MessageObject } from "@api/MessageEvents";
|
import { MessageObject } from "@api/MessageEvents";
|
||||||
import { ChannelStore, ComponentDispatch, Constants, FluxDispatcher, GuildStore, InviteActions, MaskedLink, MessageActions, ModalImageClasses, PrivateChannelsStore, RestAPI, SelectedChannelStore, SelectedGuildStore, UserProfileActions, UserProfileStore, UserSettingsActionCreators, UserUtils } from "@webpack/common";
|
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 { Channel, Guild, Message, User } from "discord-types/general";
|
||||||
|
|
||||||
import { ImageModal, ModalRoot, ModalSize, openModal } from "./modal";
|
import { MediaData, MediaModal, openModal } from "./modal";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the invite modal
|
* Open the invite modal
|
||||||
|
@ -108,25 +108,22 @@ export function sendMessage(
|
||||||
return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, extra);
|
return MessageActions.sendMessage(channelId, messageData, waitForChannelReady, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openImageModal(url: string, props?: Partial<React.ComponentProps<ImageModal>>): string {
|
/**
|
||||||
|
*
|
||||||
|
* @param media The url of the media or its data
|
||||||
|
* @param mediaModalProps Additional props for the image modal
|
||||||
|
*/
|
||||||
|
export function openMediaModal(media: string | MediaData, mediaModalProps?: Partial<React.ComponentProps<MediaModal>>): string {
|
||||||
|
media = typeof media === "string" ? { url: media } : media;
|
||||||
|
media.original ??= media.url;
|
||||||
|
media.type ??= "IMAGE";
|
||||||
return openModal(modalProps => (
|
return openModal(modalProps => (
|
||||||
<ModalRoot
|
<MediaModal
|
||||||
{...modalProps}
|
{...modalProps}
|
||||||
className={ModalImageClasses.modal}
|
{...mediaModalProps}
|
||||||
size={ModalSize.DYNAMIC}>
|
shouldAnimateCarousel
|
||||||
<ImageModal
|
items={[media]}
|
||||||
className={ModalImageClasses.image}
|
/>
|
||||||
original={url}
|
|
||||||
placeholder={url}
|
|
||||||
src={url}
|
|
||||||
renderLinkComponent={props => <MaskedLink {...props} />}
|
|
||||||
// Don't render forward message button
|
|
||||||
renderForwardComponent={() => null}
|
|
||||||
shouldHideMediaOptions={false}
|
|
||||||
shouldAnimate
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
</ModalRoot>
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,25 +101,31 @@ export const Modals = findByPropsLazy("ModalRoot", "ModalCloseButton") as {
|
||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ImageModal = ComponentType<{
|
// @TODO Type this
|
||||||
className?: string;
|
export type MediaData = {
|
||||||
src: string;
|
url: string;
|
||||||
placeholder: string;
|
original?: string;
|
||||||
original: string;
|
type?: string;
|
||||||
|
alt?: string;
|
||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
animated?: boolean;
|
|
||||||
responsive?: boolean;
|
|
||||||
renderLinkComponent(props: any): ReactNode;
|
|
||||||
renderForwardComponent(props: any): ReactNode;
|
|
||||||
maxWidth?: number;
|
maxWidth?: number;
|
||||||
maxHeight?: number;
|
maxHeight?: number;
|
||||||
shouldAnimate?: boolean;
|
} & Record<PropertyKey, any>;
|
||||||
onClose?(): void;
|
|
||||||
|
export type MediaModal = ComponentType<{
|
||||||
|
onClose?: () => void;
|
||||||
|
items: MediaData[];
|
||||||
|
startingIndex?: number;
|
||||||
|
onIndexChange?: (...args: any[]) => void;
|
||||||
|
fit?: any;
|
||||||
|
shouldRedactExplicitContent?: boolean;
|
||||||
shouldHideMediaOptions?: boolean;
|
shouldHideMediaOptions?: boolean;
|
||||||
|
shouldAnimateCarousel?: boolean;
|
||||||
|
className?: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
export const ImageModal = findComponentByCodeLazy(".MEDIA_MODAL_CLOSE", "responsive") as ImageModal;
|
export const MediaModal = findComponentByCodeLazy(".MEDIA_MODAL_CLOSE") as MediaModal;
|
||||||
|
|
||||||
export const ModalRoot = LazyComponent(() => Modals.ModalRoot);
|
export const ModalRoot = LazyComponent(() => Modals.ModalRoot);
|
||||||
export const ModalHeader = LazyComponent(() => Modals.ModalHeader);
|
export const ModalHeader = LazyComponent(() => Modals.ModalHeader);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue