From 3165f6e2aab13b4a7953ccd96196d5e9b09b056a Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 27 Jul 2026 19:27:54 -0400 Subject: [PATCH] Drop SpotifyActivityToggle --- src/components/settings/tabs/themes/index.tsx | 52 ++++++- .../clipUpload.desktop/native.ts | 2 +- .../spotifyActivityToggle/index.tsx | 136 ------------------ src/equicordplugins/themeLibrary/native.ts | 2 +- 4 files changed, 48 insertions(+), 144 deletions(-) delete mode 100644 src/equicordplugins/spotifyActivityToggle/index.tsx diff --git a/src/components/settings/tabs/themes/index.tsx b/src/components/settings/tabs/themes/index.tsx index 11b1ccfff..81ce6d728 100644 --- a/src/components/settings/tabs/themes/index.tsx +++ b/src/components/settings/tabs/themes/index.tsx @@ -19,6 +19,7 @@ import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { getStylusWebStoreUrl } from "@utils/web"; import { React, Select, showToast, TextInput, Toasts, useEffect, useMemo, useRef, useState } from "@webpack/common"; +import { SyntheticEvent } from "react"; import { OnlineThemesSection } from "./OnlineThemes"; import { QuickActionsSection } from "./QuickActions"; @@ -113,12 +114,7 @@ function ThemesTab() { } } - async function onFileUpload(e: React.SyntheticEvent) { - e.stopPropagation(); - e.preventDefault(); - if (!e.currentTarget?.files?.length) return; - const { files } = e.currentTarget; - + async function doUploadThemes(files: ArrayLike) { const uploads = Array.from(files, file => { const { name } = file; if (!name.endsWith(".css")) return; @@ -138,6 +134,47 @@ function ThemesTab() { refreshLocalThemes(); } + async function onFileUpload(e: SyntheticEvent) { + e.stopPropagation(); + e.preventDefault(); + + if (!e.currentTarget?.files?.length) return; + await doUploadThemes(e.currentTarget.files); + } + + function useDropFile(refreshThemes: Function) { + useEffect(() => { + const onDragOver = (e: DragEvent) => { + if (!e.dataTransfer?.items.length) return; + if (!Array.from(e.dataTransfer.items).some(item => item.kind === "file" && item.getAsFile()?.name.endsWith(".css"))) + return; + + e.preventDefault(); + e.dataTransfer.dropEffect = "copy"; + }; + + const onDrop = async (e: DragEvent) => { + e.preventDefault(); + + if (!e.dataTransfer?.files.length) return; + + await doUploadThemes( + Array.from(e.dataTransfer.files).filter(file => file.name.endsWith(".css")) + ); + + refreshThemes(); + }; + + window.addEventListener("dragover", onDragOver); + window.addEventListener("drop", onDrop); + + return () => { + window.removeEventListener("dragover", onDragOver); + window.removeEventListener("drop", onDrop); + }; + }, []); + } + function addThemeLink(link: string) { if (!themeLinkValid) return; if (settings.themeLinks.includes(link)) return; @@ -147,6 +184,9 @@ function ThemesTab() { refreshOnlineThemes(); } + // This condition is compile time so conditional hook is okay + if (IS_WEB) useDropFile(refreshLocalThemes); + async function refreshOnlineThemes() { const themes = await Promise.all( settings.themeLinks.map(async link => { diff --git a/src/equicordplugins/clipUpload.desktop/native.ts b/src/equicordplugins/clipUpload.desktop/native.ts index df2f51758..af24fcc2f 100644 --- a/src/equicordplugins/clipUpload.desktop/native.ts +++ b/src/equicordplugins/clipUpload.desktop/native.ts @@ -4,8 +4,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { ensureSafePath } from "@main/ipcMain"; import { DATA_DIR } from "@main/utils/constants"; +import { ensureSafePath } from "@main/utils/ensureSafePath"; import { randomUUID } from "crypto"; import { dialog, type IpcMainInvokeEvent } from "electron"; import { mkdir, readFile, rm, writeFile } from "fs/promises"; diff --git a/src/equicordplugins/spotifyActivityToggle/index.tsx b/src/equicordplugins/spotifyActivityToggle/index.tsx deleted file mode 100644 index 65ff76b7f..000000000 --- a/src/equicordplugins/spotifyActivityToggle/index.tsx +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2025 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import { isPluginEnabled } from "@api/PluginManager"; -import { definePluginSettings } from "@api/Settings"; -import { UserAreaButton, UserAreaRenderProps } from "@api/UserArea"; -import equicordToolbox from "@equicordplugins/equicordToolbox"; -import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; -import { Constants, Menu, RestAPI, useEffect, useState } from "@webpack/common"; - -let spotifyId: string | null = null; -let showActivity = false; -let isLoaded = false; -let forceUpdate: (() => void) | null = null; - -function SpotifyIcon({ className, enabled }: { className?: string; enabled: boolean; }) { - const redLinePath = "M48.54 4.54a2.2 2.2 0 0 0-3.08-3.08l-44 44a2.2 2.2 0 1 0 3.08 3.08Z"; - const maskBlackPath = "M50.376 8.248 41.752-.376-.376 41.752 8.248 50.376Z"; - - return ( - - - {!enabled && <> - - - - - - } - - ); -} - -function SpotifyActivityToggleButton({ iconForeground, hideTooltips, nameplate }: UserAreaRenderProps) { - const { location } = settings.use(["location"]); - const [, rerender] = useState(0); - - useEffect(() => { - forceUpdate = () => rerender(n => n + 1); - return () => { forceUpdate = null; }; - }, []); - - if (!isLoaded || !spotifyId || location !== "PANEL" && isPluginEnabled(equicordToolbox.name)) return null; - - return ( - } - role="switch" - aria-checked={showActivity} - redGlow={!showActivity} - plated={nameplate != null} - onClick={async () => { - showActivity = !showActivity; - forceUpdate?.(); - - await RestAPI.patch({ - url: Constants.Endpoints.CONNECTION("spotify", spotifyId), - body: { show_activity: showActivity }, - }); - }} - /> - ); -} - -const settings = definePluginSettings({ - location: { - type: OptionType.SELECT, - description: "Where to show the Spotify toggle button.", - options: [ - { label: "Next to Mute/Deafen", value: "PANEL", default: true }, - { label: "Equicord Toolbox", value: "TOOLBOX" } - ], - get hidden() { - return !isPluginEnabled(equicordToolbox.name); - } - }, -}); - -export default definePlugin({ - name: "SpotifyActivityToggle", - description: "Adds a toggle button for Spotify activity visibility.", - dependencies: ["UserAreaAPI"], - tags: ["Activity", "Utility"], - authors: [Devs.thororen], - settings, - - userAreaButton: { - icon: (props: { className?: string; }) => , - render: SpotifyActivityToggleButton - }, - - toolboxActions() { - const { location } = settings.use(["location"]); - - if (!spotifyId || location !== "TOOLBOX") return null; - - return ( - { - showActivity = !showActivity; - - await RestAPI.patch({ - url: Constants.Endpoints.CONNECTION("spotify", spotifyId), - body: { show_activity: showActivity }, - }); - }} - /> - ); - }, - - flux: { - async CONNECTION_OPEN() { - const { body } = await RestAPI.get({ url: Constants.Endpoints.CONNECTIONS }); - if (!body) return; - - const spotifyConn = body.find((c: { type: string; }) => c.type === "spotify"); - if (spotifyConn) { - spotifyId = spotifyConn.id; - showActivity = spotifyConn.show_activity; - } - isLoaded = true; - forceUpdate?.(); - } - }, -}); diff --git a/src/equicordplugins/themeLibrary/native.ts b/src/equicordplugins/themeLibrary/native.ts index a6d605a11..4fc8be676 100644 --- a/src/equicordplugins/themeLibrary/native.ts +++ b/src/equicordplugins/themeLibrary/native.ts @@ -4,8 +4,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { ensureSafePath } from "@main/ipcMain"; import { THEMES_DIR } from "@main/utils/constants"; +import { ensureSafePath } from "@main/utils/ensureSafePath"; import { IpcMainInvokeEvent } from "electron"; import { existsSync, writeFileSync } from "fs";