From ba6d23a31f61841e190e771b1ccc4d5d18e666db Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 9 Jan 2024 17:39:38 +0100 Subject: [PATCH 1/5] fix adding View Raw to undesired channel context menus --- src/plugins/permissionsViewer/index.tsx | 4 +++- src/plugins/viewRaw/index.tsx | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/plugins/permissionsViewer/index.tsx b/src/plugins/permissionsViewer/index.tsx index 985b23842..9e0131e64 100644 --- a/src/plugins/permissionsViewer/index.tsx +++ b/src/plugins/permissionsViewer/index.tsx @@ -126,7 +126,9 @@ function MenuItem(guildId: string, id?: string, type?: MenuItemParentType) { function makeContextMenuPatch(childId: string | string[], type?: MenuItemParentType): NavContextMenuPatchCallback { return (children, props) => () => { - if (!props || (type === MenuItemParentType.User && !props.user) || (type === MenuItemParentType.Guild && !props.guild)) return children; + if (!props) return; + if ((type === MenuItemParentType.User && !props.user) || (type === MenuItemParentType.Guild && !props.guild) || (type === MenuItemParentType.Channel && (!props.channel || !props.guild))) + return children; const group = findGroupChildrenByChildId(childId, children); diff --git a/src/plugins/viewRaw/index.tsx b/src/plugins/viewRaw/index.tsx index f516b5d7a..187dbc4e3 100644 --- a/src/plugins/viewRaw/index.tsx +++ b/src/plugins/viewRaw/index.tsx @@ -117,22 +117,26 @@ const settings = definePluginSettings({ } }); -function MakeContextCallback(name: string) { +function MakeContextCallback(name: "Guild" | "User" | "Channel") { const callback: NavContextMenuPatchCallback = (children, props) => () => { - if ((name === "Guild" && !props.guild) || (name === "User" && !props.user)) return; + const value = props[name.toLowerCase()]; + if (!value) return; + if (props.label === "Channel Actions") return; // random shit like notification settings + const lastChild = children.at(-1); if (lastChild?.key === "developer-actions") { const p = lastChild.props; if (!Array.isArray(p.children)) p.children = [p.children]; - ({ children } = p); + + children = p.children; } children.splice(-1, 0, openViewRawModal(JSON.stringify(props[name.toLowerCase()], null, 4), name)} + action={() => openViewRawModal(JSON.stringify(value, null, 4), name)} icon={CopyIcon} /> ); From 8c890028672be7623949ab1aa45bc5796c773a48 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Tue, 9 Jan 2024 17:44:18 +0100 Subject: [PATCH 2/5] forgor not everyone uses enlgihs --- src/plugins/viewRaw/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/viewRaw/index.tsx b/src/plugins/viewRaw/index.tsx index 187dbc4e3..08acdc4c5 100644 --- a/src/plugins/viewRaw/index.tsx +++ b/src/plugins/viewRaw/index.tsx @@ -27,7 +27,7 @@ import { Margins } from "@utils/margins"; import { copyWithToast } from "@utils/misc"; import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, ChannelStore, Forms, Menu, Text } from "@webpack/common"; +import { Button, ChannelStore, Forms, i18n, Menu, Text } from "@webpack/common"; import { Message } from "discord-types/general"; @@ -121,7 +121,7 @@ function MakeContextCallback(name: "Guild" | "User" | "Channel") { const callback: NavContextMenuPatchCallback = (children, props) => () => { const value = props[name.toLowerCase()]; if (!value) return; - if (props.label === "Channel Actions") return; // random shit like notification settings + if (props.label === i18n.Messages.CHANNEL_ACTIONS_MENU_LABEL) return; // random shit like notification settings const lastChild = children.at(-1); if (lastChild?.key === "developer-actions") { From cb7045c00bb7bbeba4b70d3a1806069878a456f3 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 13 Jan 2024 19:05:01 +0100 Subject: [PATCH 3/5] WebContextMenus: use vesktop native clipboard - fixes some permission issues --- src/plugins/webContextMenus.web/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/webContextMenus.web/index.ts b/src/plugins/webContextMenus.web/index.ts index 50a1b90a7..bb98c61d7 100644 --- a/src/plugins/webContextMenus.web/index.ts +++ b/src/plugins/webContextMenus.web/index.ts @@ -182,6 +182,12 @@ export default definePlugin({ ], async copyImage(url: string) { + if (IS_VESKTOP && VesktopNative.clipboard) { + const data = await fetch(url).then(r => r.arrayBuffer()); + VesktopNative.clipboard.copyImage(data, url); + return; + } + // Clipboard only supports image/png, jpeg and similar won't work. Thus, we need to convert it to png // via canvas first const img = new Image(); From 69a4d2734efcfd4e1ceed18b61e56d91ec446876 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 13 Jan 2024 19:08:11 +0100 Subject: [PATCH 4/5] fix(git updater): correctly persist isDev switch --- src/main/updater/git.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/updater/git.ts b/src/main/updater/git.ts index e96026443..2ff3ba512 100644 --- a/src/main/updater/git.ts +++ b/src/main/updater/git.ts @@ -73,6 +73,8 @@ async function build() { const command = isFlatpak ? "flatpak-spawn" : "node"; const args = isFlatpak ? ["--host", "node", "scripts/build/build.mjs"] : ["scripts/build/build.mjs"]; + if (IS_DEV) args.push("--dev"); + const res = await execFile(command, args, opts); return !res.stderr.includes("Build failed"); From 2ab1c50c7355849e42ad81afcfef3d008b459247 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sat, 13 Jan 2024 19:27:41 +0100 Subject: [PATCH 5/5] QuickCss: reopen existing window instead of new one --- src/main/ipcMain.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/ipcMain.ts b/src/main/ipcMain.ts index 6254bc826..47d400eb6 100644 --- a/src/main/ipcMain.ts +++ b/src/main/ipcMain.ts @@ -139,8 +139,15 @@ export function initIpc(mainWindow: BrowserWindow) { } ipcMain.handle(IpcEvents.OPEN_MONACO_EDITOR, async () => { + const title = "Vencord QuickCSS Editor"; + const existingWindow = BrowserWindow.getAllWindows().find(w => w.title === title); + if (existingWindow && !existingWindow.isDestroyed()) { + existingWindow.focus(); + return; + } + const win = new BrowserWindow({ - title: "Vencord QuickCSS Editor", + title, autoHideMenuBar: true, darkTheme: true, webPreferences: {