From 0f61bca0c500ab1f122d121fd99a579d8921284a Mon Sep 17 00:00:00 2001 From: byeoon <47872200+byeoon@users.noreply.github.com> Date: Thu, 6 Feb 2025 21:59:27 -0500 Subject: [PATCH] revert changes that broke the code --- src/plugins/copyStickerLinks/index.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/copyStickerLinks/index.tsx b/src/plugins/copyStickerLinks/index.tsx index 3b369b90e..0e8c38b59 100644 --- a/src/plugins/copyStickerLinks/index.tsx +++ b/src/plugins/copyStickerLinks/index.tsx @@ -61,7 +61,7 @@ async function fetchSticker(id: string) { return body as Sticker; } -function buildMenuItem(stickerId: string) { +function buildMenuItem(type: "Sticker", fetchData: () => Promisable>) { return ( <> @@ -103,13 +103,18 @@ function buildMenuItem(stickerId: string) { const messageContextMenuPatch: NavContextMenuPatchCallback = (children, props) => { const { favoriteableId, favoriteableType } = props ?? {}; if (!favoriteableId) return; - if (favoriteableType != "sticker") return; + const menuItem = (() => { + switch (favoriteableType) { + case "sticker": + const sticker = props.message.stickerItems.find(s => s.id === favoriteableId); + if (sticker?.format_type === 3) return; - const sticker = props.message.stickerItems.find(s => s.id === favoriteableId); - if (sticker?.format_type === 3) return; + return buildMenuItem("Sticker", () => fetchSticker(favoriteableId)); + } + })(); - const menuItem = buildMenuItem("Sticker", () => fetchSticker(favoriteableId); - findGroupChildrenByChildId("devmode-copy-id", children, true)?.push(menuItem); + if (menuItem) + findGroupChildrenByChildId("devmode-copy-id", children, true)?.push(menuItem); }; const expressionPickerPatch: NavContextMenuPatchCallback = (children, props: { target: HTMLElement; }) => {