Fix Gif Picker Context Menus

This commit is contained in:
thororen 2026-09-07 12:39:16 -04:00
parent 3b09e2cdac
commit f62f8eaa84
No known key found for this signature in database
5 changed files with 58 additions and 2 deletions

View file

@ -1435,3 +1435,21 @@ export function FireIcon(props: IconProps) {
</Icon>
);
}
export function RemixIcon(props: IconProps) {
return (
<Icon
{...props}
viewBox="0 0 24 24"
>
<path
fill={props.fill || "currentColor"}
d="M6 3a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v6a1 1 0 1 1-2 0V5.41l-6.64 6.64A4.66 4.66 0 0 0 4 15.35V17a3 3 0 0 0 3 3 1 1 0 1 1 0 2 5 5 0 0 1-5-5v-1.66c0-1.76.7-3.46 1.95-4.7L10.59 4H7a1 1 0 0 1-1-1Z"
/>
<path
fill={props.fill || "currentColor"}
d="M18 21a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1v-6a1 1 0 1 1 2 0v3.59l6.64-6.64A4.66 4.66 0 0 0 20 8.65V7a3 3 0 0 0-3-3 1 1 0 1 1 0-2 5 5 0 0 1 5 5v1.66c0 1.76-.7 3.46-1.95 4.7L13.41 20H17a1 1 0 0 1 1 1Z"
/>
</Icon>
);
}

View file

@ -359,6 +359,14 @@ export default definePlugin({
}
]
},
// gif-picker context menu doesnt get full context so give it
{
find: "renderEmptyFavorite",
replacement: {
match: /(?<=handleContextMenu.{0,150})(?=link:(\i)\.url)/,
replace: "...$1,"
}
}
],
renderMessageAccessory(props) {
return (

View file

@ -5,6 +5,7 @@
*/
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
import { FolderIcon, InfoIcon, LinkIcon, PencilIcon, PlusIcon, RemixIcon, TrashIcon } from "@components/Icons";
import { copyToClipboard } from "@utils/clipboard";
import { Alerts, Button, FluxDispatcher, Menu, showToast, Toasts } from "@webpack/common";
@ -23,7 +24,13 @@ function dispatchRefresh(collectionName: string) {
function AddToCollectionMenu(gif: Gif) {
return (
<Menu.MenuItem label="Add To Collection" key="add-to-collection" id="add-to-collection">
<Menu.MenuItem
label="Add To Collection"
key="add-to-collection"
id="add-to-collection"
icon={FolderIcon}
leadingAccessory={{ type: "icon", icon: FolderIcon }}
>
{cache_collections.length > 0 && cache_collections.map(col => (
<Menu.MenuItem
key={col.name}
@ -37,6 +44,8 @@ function AddToCollectionMenu(gif: Gif) {
key="create-collection"
id="create-collection"
label="Create Collection"
icon={PlusIcon}
leadingAccessory={{ type: "icon", icon: PlusIcon }}
action={() => openCreateCollectionModal(gif)}
/>
</Menu.MenuItem>
@ -58,6 +67,8 @@ export const addCollectionContextMenuPatch: NavContextMenuPatchCallback = (child
label="Copy Image Link"
key="copy-image-link"
id="copy-image-link"
icon={LinkIcon}
leadingAccessory={{ type: "icon", icon: LinkIcon }}
action={() => {
copyToClipboard(gif.url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS);
@ -78,6 +89,8 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti
key="collection-information"
id="collection-information"
label="Collection Information"
icon={InfoIcon}
leadingAccessory={{ type: "icon", icon: InfoIcon }}
action={() => {
const collection = cache_collections.find(c => c.name === nameOrId);
if (collection) openCollectionInfoModal(collection);
@ -88,6 +101,8 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti
key="rename-collection"
id="rename-collection"
label="Rename"
icon={PencilIcon}
leadingAccessory={{ type: "icon", icon: PencilIcon }}
action={() => openRenameCollectionModal(nameOrId)}
/>
</>
@ -98,6 +113,8 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti
key="gif-information"
id="gif-information"
label="Information"
icon={InfoIcon}
leadingAccessory={{ type: "icon", icon: InfoIcon }}
action={() => {
const gif = getGifById(nameOrId);
if (gif) openGifInfoModal(gif);
@ -108,6 +125,8 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti
key="copy-url"
id="copy-url"
label="Copy URL"
icon={LinkIcon}
leadingAccessory={{ type: "icon", icon: LinkIcon }}
action={() => {
const gif = getGifById(nameOrId);
if (!gif) return;
@ -119,6 +138,8 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti
key="move-to-collection"
id="move-to-collection"
label="Move To Collection"
icon={RemixIcon}
leadingAccessory={{ type: "icon", icon: RemixIcon }}
action={() => openMoveToCollectionModal(nameOrId)}
/>
<Menu.MenuSeparator key="gif-sep-2" />
@ -128,6 +149,8 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti
key="delete-collection"
id="delete-collection"
label={type === "collection" ? "Delete Collection" : "Remove"}
icon={TrashIcon}
leadingAccessory={{ type: "icon", icon: TrashIcon }}
action={() => {
const doDelete = async () => {
if (type === "collection") {
@ -171,6 +194,8 @@ export function GifPickerContextMenu({ gif }: { gif: Gif; }) {
label="Copy Image Link"
key="copy-image-link"
id="copy-image-link"
icon={LinkIcon}
leadingAccessory={{ type: "icon", icon: LinkIcon }}
action={() => {
copyToClipboard(gif.url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS);
@ -191,6 +216,8 @@ export function getGifPickerContextMenuItems(src: string, url: string, height: n
label="Copy Image Link"
key="copy-image-link"
id="copy-image-link"
icon={LinkIcon}
leadingAccessory={{ type: "icon", icon: LinkIcon }}
action={() => {
copyToClipboard(url);
showToast("Image link copied to clipboard", Toasts.Type.SUCCESS);

View file

@ -90,7 +90,7 @@ export default definePlugin({
match: /(\i)\.name\),renderExtras:this\.renderCategoryExtras,/,
replace: "$&onContextMenu:(e)=>$self.openCategoryContextMenu(e,$1),"
}
},
}
],
start() {

View file

@ -7,6 +7,7 @@
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { definePluginSettings, migratePluginSettings } from "@api/Settings";
import { Button } from "@components/Button";
import { RemixIcon } from "@components/Icons";
import { EquicordDevs } from "@utils/constants";
import { classNameFactory } from "@utils/css";
import { getCurrentChannel } from "@utils/discord";
@ -129,6 +130,8 @@ const gifPickerContextMenuPatch: NavContextMenuPatchCallback = (children, props)
id="gif-maker-edit"
key="gif-maker-edit"
label="Edit GIF"
icon={RemixIcon}
leadingAccessory={{ type: "icon", icon: RemixIcon }}
action={() => openGifMakerFromItem(props)}
/>
);