CopyStickerLinks: Update

This commit is contained in:
thororen1234 2025-07-31 14:41:31 -04:00
parent 3770544482
commit f743850556
No known key found for this signature in database
2 changed files with 16 additions and 42 deletions

View file

@ -48,18 +48,18 @@
"@vap/shiki": "0.10.5",
"fflate": "^0.8.2",
"gifenc": "github:mattdesl/gifenc#64842fca317b112a8590f8fef2bf3825da8f6fe3",
"jsqr": "1.4.0",
"idb": "8.0.3",
"jsqr": "1.4.0",
"monaco-editor": "^0.52.2",
"nanoid": "^5.1.5",
"openai": "^4.30.0",
"socket.io": "^4.8.1",
"usercss-meta": "^0.12.0",
"openai": "^4.30.0",
"virtual-merge": "^1.0.1"
},
"devDependencies": {
"@stylistic/eslint-plugin": "^4.2.0",
"@electron/asar": "^3.2.10",
"@stylistic/eslint-plugin": "^4.2.0",
"@types/chrome": "^0.0.312",
"@types/diff": "^7.0.2",
"@types/lodash": "^4.17.14",
@ -94,7 +94,7 @@
"zip-local": "^0.3.5",
"zustand": "^3.7.2"
},
"packageManager": "pnpm@10.4.1",
"packageManager": "pnpm@10.14.0",
"pnpm": {
"patchedDependencies": {
"eslint@9.20.1": "patches/eslint@9.20.1.patch",

View file

@ -18,7 +18,7 @@ interface Sticker {
type: number;
}
const StickerExt = ["png", "png", "json", "gif"] as const;
const StickerExt = [, "png", "png", "json", "gif"] as const;
function getUrl(data: Sticker) {
if (data.format_type === 4)
@ -32,39 +32,6 @@ function buildMenuItem(Sticker, fetchData: () => Promisable<Omit<Sticker, "t">>)
<>
<Menu.MenuSeparator></Menu.MenuSeparator>
<Menu.MenuItem
id="copystickerurl"
key="copystickerurl"
label={"Copy URL"}
action={async () => {
const res = await fetchData();
const data = { t: Sticker, ...res } as Sticker;
const url = getUrl(data[0]);
copyWithToast(url, "Link copied!");
}
}
/>
<Menu.MenuItem
id="openstickerlink"
key="openstickerlink"
label={"Open URL"}
action={async () => {
const res = await fetchData();
const data = { t: Sticker, ...res } as Sticker;
const url = getUrl(data[0]);
VencordNative.native.openExternal(url);
}
}
/>
</>
);
}
function buildMenuExpression(Sticker, fetchData: () => Promisable<Omit<Sticker, "t">>) {
return (
<>
<Menu.MenuSeparator></Menu.MenuSeparator>
<Menu.MenuItem
id="copystickerurl"
key="copystickerurl"
@ -77,6 +44,7 @@ function buildMenuExpression(Sticker, fetchData: () => Promisable<Omit<Sticker,
}
}
/>
<Menu.MenuItem
id="openstickerlink"
key="openstickerlink"
@ -96,12 +64,13 @@ function buildMenuExpression(Sticker, fetchData: () => Promisable<Omit<Sticker,
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
const { favoriteableId, favoriteableType } = props ?? {};
if (!favoriteableId) return;
const menuItem = (() => {
const sticker = props.message.stickerItems.find(s => s.id === favoriteableId);
if (sticker?.format_type === 3) return;
switch (favoriteableType) {
case "sticker":
return buildMenuItem("Sticker", () => props.message.stickerItems);
const sticker = props.message.stickerItems.find(s => s.id === favoriteableId);
if (!sticker?.format_type) return;
return buildMenuItem("Sticker", () => props.message.stickerItems[0]);
}
})();
@ -116,7 +85,12 @@ const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { t
if (!props.target.className?.includes("lottieCanvas")) {
const stickerCache = StickerStore.getStickerById(id);
if (stickerCache) {
children.push(buildMenuExpression("Sticker", () => stickerCache));
const stickerInfo = {
format_type: stickerCache.format_type,
id: stickerCache.id,
type: stickerCache.type
};
children.push(buildMenuItem("Sticker", () => stickerInfo));
}
}
};