mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-16 18:07:02 -04:00
Make Context Menu API support hooks (#902)
Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
parent
e8809fc57b
commit
96f640da67
10 changed files with 29 additions and 24 deletions
|
@ -238,8 +238,8 @@ function initWs(isManual = false) {
|
|||
});
|
||||
}
|
||||
|
||||
const contextMenuPatch: NavContextMenuPatchCallback = kids => {
|
||||
kids.unshift(
|
||||
const contextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
||||
children.unshift(
|
||||
<Menu.MenuItem
|
||||
id={NAV_ID}
|
||||
label="Reconnect Dev Companion"
|
||||
|
|
|
@ -210,7 +210,7 @@ function isGifUrl(url: string) {
|
|||
return new URL(url).pathname.endsWith(".gif");
|
||||
}
|
||||
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => {
|
||||
const { favoriteableId, itemHref, itemSrc, favoriteableType } = props ?? {};
|
||||
|
||||
if (!favoriteableId || favoriteableType !== "emoji") return;
|
||||
|
@ -223,7 +223,7 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) =
|
|||
if (group) group.push(buildMenuItem(favoriteableId, name, isGifUrl(itemHref ?? itemSrc)));
|
||||
};
|
||||
|
||||
const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { target: HTMLElement; }) => {
|
||||
const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { target: HTMLElement; }) => () => {
|
||||
const { id, name, type } = props?.target?.dataset ?? {};
|
||||
if (!id || !name || type !== "emoji") return;
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ export const settings = definePluginSettings({
|
|||
});
|
||||
|
||||
|
||||
const imageContextMenuPatch: NavContextMenuPatchCallback = (children, _) => {
|
||||
const imageContextMenuPatch: NavContextMenuPatchCallback = children => () => {
|
||||
children.push(
|
||||
<Menu.MenuGroup id="image-zoom">
|
||||
{/* thanks SpotifyControls */}
|
||||
|
|
|
@ -44,7 +44,7 @@ function addDeleteStyle() {
|
|||
}
|
||||
|
||||
const MENU_ITEM_ID = "message-logger-remove-history";
|
||||
const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) => {
|
||||
const patchMessageContextMenu: NavContextMenuPatchCallback = (children, props) => () => {
|
||||
const { message } = props;
|
||||
const { deleted, editHistory, id, channel_id } = message;
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ function PinMenuItem(channelId: string) {
|
|||
);
|
||||
}
|
||||
|
||||
const GroupDMContext: NavContextMenuPatchCallback = (children, props) => {
|
||||
const GroupDMContext: NavContextMenuPatchCallback = (children, props) => () => {
|
||||
const container = findGroupChildrenByChildId("leave-channel", children);
|
||||
if (container)
|
||||
container.unshift(PinMenuItem(props.channel.id));
|
||||
};
|
||||
|
||||
const UserContext: NavContextMenuPatchCallback = (children, props) => {
|
||||
const UserContext: NavContextMenuPatchCallback = (children, props) => () => {
|
||||
const container = findGroupChildrenByChildId("close-dm", children);
|
||||
if (container) {
|
||||
const idx = container.findIndex(c => c?.props?.id === "close-dm");
|
||||
|
|
|
@ -34,7 +34,7 @@ function search(src: string, engine: string) {
|
|||
open(engine + encodeURIComponent(src), "_blank");
|
||||
}
|
||||
|
||||
const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
|
||||
const imageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => () => {
|
||||
if (!props) return;
|
||||
const { reverseImageSearchType, itemHref, itemSrc } = props;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ const ReplyIcon = LazyComponent(() => findByCode("M10 8.26667V4L3 11.4667L10 18.
|
|||
|
||||
const replyFn = findByCodeLazy("showMentionToggle", "TEXTAREA_FOCUS", "shiftKey");
|
||||
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => {
|
||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => () => {
|
||||
// make sure the message is in the selected channel
|
||||
if (SelectedChannelStore.getChannelId() !== message.channel_id) return;
|
||||
|
||||
|
@ -61,7 +61,6 @@ const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { messag
|
|||
/>
|
||||
));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ export default definePlugin({
|
|||
// doesn't contain our sections. This patches the actions of our
|
||||
// sections to manually use SettingsRouter (which only works on desktop
|
||||
// but the context menu is usually not available on mobile anyway)
|
||||
addContextMenuPatch("user-settings-cog", children => {
|
||||
addContextMenuPatch("user-settings-cog", children => () => {
|
||||
const section = children.find(c => Array.isArray(c) && c.some(it => it?.props?.id === "VencordSettings")) as any;
|
||||
section?.forEach(c => {
|
||||
if (c?.props?.id?.startsWith("Vencord")) {
|
||||
|
|
|
@ -81,7 +81,7 @@ function openImage(url: string) {
|
|||
));
|
||||
}
|
||||
|
||||
const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: UserContextProps) => {
|
||||
const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: UserContextProps) => () => {
|
||||
const memberAvatar = GuildMemberStore.getMember(guildId!, user.id)?.avatar || null;
|
||||
|
||||
children.splice(1, 0, (
|
||||
|
@ -106,7 +106,7 @@ const UserContext: NavContextMenuPatchCallback = (children, { user, guildId }: U
|
|||
));
|
||||
};
|
||||
|
||||
const GuildContext: NavContextMenuPatchCallback = (children, { guild: { id, icon, banner } }: GuildContextProps) => {
|
||||
const GuildContext: NavContextMenuPatchCallback = (children, { guild: { id, icon, banner } }: GuildContextProps) => () => {
|
||||
if (!banner && !icon) return;
|
||||
|
||||
// before copy id (if it exists)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue