diff --git a/src/plugins/betterActivities/components/ActivityTooltip.tsx b/src/equicordplugins/betterActivities/components/ActivityTooltip.tsx similarity index 100% rename from src/plugins/betterActivities/components/ActivityTooltip.tsx rename to src/equicordplugins/betterActivities/components/ActivityTooltip.tsx diff --git a/src/plugins/betterActivities/components/Caret.tsx b/src/equicordplugins/betterActivities/components/Caret.tsx similarity index 100% rename from src/plugins/betterActivities/components/Caret.tsx rename to src/equicordplugins/betterActivities/components/Caret.tsx diff --git a/src/plugins/betterActivities/components/SpotifyIcon.tsx b/src/equicordplugins/betterActivities/components/SpotifyIcon.tsx similarity index 100% rename from src/plugins/betterActivities/components/SpotifyIcon.tsx rename to src/equicordplugins/betterActivities/components/SpotifyIcon.tsx diff --git a/src/plugins/betterActivities/components/TwitchIcon.tsx b/src/equicordplugins/betterActivities/components/TwitchIcon.tsx similarity index 100% rename from src/plugins/betterActivities/components/TwitchIcon.tsx rename to src/equicordplugins/betterActivities/components/TwitchIcon.tsx diff --git a/src/plugins/betterActivities/index.tsx b/src/equicordplugins/betterActivities/index.tsx similarity index 98% rename from src/plugins/betterActivities/index.tsx rename to src/equicordplugins/betterActivities/index.tsx index 1150331b..14abefab 100644 --- a/src/plugins/betterActivities/index.tsx +++ b/src/equicordplugins/betterActivities/index.tsx @@ -18,6 +18,7 @@ import "./styles.css"; +import { migratePluginSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; @@ -43,6 +44,8 @@ const ActivityView = findComponentByCodeLazy("onOpenGameProfi // if discord one day decides to change their icon this needs to be updated const DefaultActivityIcon = findComponentByCodeLazy("M6,7 L2,7 L2,6 L6,6 L6,7 Z M8,5 L2,5 L2,4 L8,4 L8,5 Z M8,3 L2,3 L2,2 L8,2 L8,3 Z M8.88888889,0 L1.11111111,0 C0.494444444,0 0,0.494444444 0,1.11111111 L0,8.88888889 C0,9.50253861 0.497461389,10 1.11111111,10 L8.88888889,10 C9.50253861,10 10,9.50253861 10,8.88888889 L10,1.11111111 C10,0.494444444 9.5,0 8.88888889,0 Z"); + +migratePluginSettings("MemberListActivites", "BetterActivities"); export default definePlugin({ name: "BetterActivities", description: "Shows activity icons in the member list and allows showing all activities", diff --git a/src/plugins/betterActivities/settings.tsx b/src/equicordplugins/betterActivities/settings.tsx similarity index 100% rename from src/plugins/betterActivities/settings.tsx rename to src/equicordplugins/betterActivities/settings.tsx diff --git a/src/plugins/betterActivities/styles.css b/src/equicordplugins/betterActivities/styles.css similarity index 100% rename from src/plugins/betterActivities/styles.css rename to src/equicordplugins/betterActivities/styles.css diff --git a/src/plugins/betterActivities/types.ts b/src/equicordplugins/betterActivities/types.ts similarity index 100% rename from src/plugins/betterActivities/types.ts rename to src/equicordplugins/betterActivities/types.ts diff --git a/src/plugins/betterActivities/utils.ts b/src/equicordplugins/betterActivities/utils.ts similarity index 100% rename from src/plugins/betterActivities/utils.ts rename to src/equicordplugins/betterActivities/utils.ts diff --git a/src/plugins/memberListActivites/components/SpotifyIcon.tsx b/src/plugins/memberListActivites/components/SpotifyIcon.tsx deleted file mode 100644 index 9210169e..00000000 --- a/src/plugins/memberListActivites/components/SpotifyIcon.tsx +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import type { SVGProps } from "react"; - -export function SpotifyIcon(props: SVGProps) { - return (); -} diff --git a/src/plugins/memberListActivites/components/TwitchIcon.tsx b/src/plugins/memberListActivites/components/TwitchIcon.tsx deleted file mode 100644 index f0246c16..00000000 --- a/src/plugins/memberListActivites/components/TwitchIcon.tsx +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors - * SPDX-License-Identifier: GPL-3.0-or-later - */ - -import type { SVGProps } from "react"; - -export function TwitchIcon(props: SVGProps) { - return (); -} diff --git a/src/plugins/memberListActivites/index.tsx b/src/plugins/memberListActivites/index.tsx deleted file mode 100644 index 3df0537d..00000000 --- a/src/plugins/memberListActivites/index.tsx +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Vencord, a modification for Discord's desktop app - * Copyright (c) 2023 Vendicated and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . -*/ - -import "./styles.css"; - -import { definePluginSettings } from "@api/Settings"; -import { classNameFactory } from "@api/Styles"; -import ErrorBoundary from "@components/ErrorBoundary"; -import { Devs } from "@utils/constants"; -import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; -import { Tooltip } from "@webpack/common"; -import type { ImgHTMLAttributes } from "react"; - -import { SpotifyIcon } from "./components/SpotifyIcon"; -import { TwitchIcon } from "./components/TwitchIcon"; - -const settings = definePluginSettings({ - iconSize: { - type: OptionType.SLIDER, - description: "Size of the activity icons", - markers: [10, 15, 20], - default: 20, - stickToMarkers: false, - }, - renderGifs: { - type: OptionType.BOOLEAN, - description: "Allow rendering GIFs", - default: true, - restartNeeded: false, - }, -}); - -interface Activity { - created_at: number; - id: string; - name: string; - type: number; - emoji?: { - animated: boolean; - id: string; - name: string; - }; - state?: string; - flags?: number; - sync_id?: string; - details?: string; - application_id?: string; - assets?: { - large_text?: string; - large_image?: string; - small_text?: string; - small_image?: string; - }; - platform?: string; -} - -const cl = classNameFactory("vc-mla-"); - -interface Application { - id: string; - name: string; - icon: string; - description: string; - summary: string; - type: number; - hook: boolean; - guild_id: string; - executables: Executable[]; - verify_key: string; - publishers: Developer[]; - developers: Developer[]; - flags: number; -} - -interface Developer { - id: string; - name: string; -} - -interface Executable { - os: string; - name: string; - is_launcher: boolean; -} - -interface ApplicationIcon { - image: ImgHTMLAttributes & { - src: string; - alt: string; - }; - activity: Activity; -} - -interface ActivityListIcon { - iconElement: JSX.Element; - tooltip?: JSX.Element | string; -} - -const ApplicationStore: { - getApplication: (id: string) => Application | null; -} = findStoreLazy("ApplicationStore"); - -const { fetchApplication }: { - fetchApplication: (id: string) => Promise; -} = findByPropsLazy("fetchApplication"); - -// if discord one day decides changes their icon this needs to be updated -const DefaultActivityIcon = findComponentByCodeLazy("M6,7 L2,7 L2,6 L6,6 L6,7 Z M8,5 L2,5 L2,4 L8,4 L8,5 Z M8,3 L2,3 L2,2 L8,2 L8,3 Z M8.88888889,0 L1.11111111,0 C0.494444444,0 0,0.494444444 0,1.11111111 L0,8.88888889 C0,9.50253861 0.497461389,10 1.11111111,10 L8.88888889,10 C9.50253861,10 10,9.50253861 10,8.88888889 L10,1.11111111 C10,0.494444444 9.5,0 8.88888889,0 Z"); - -const fetchedApplications = new Map(); - -const xboxUrl = "https://discord.com/assets/9a15d086141be29d9fcd.png"; - -function getApplicationIcons(activities: Activity[]) { - const applicationIcons: ApplicationIcon[] = []; - const applications = activities.filter(activity => activity.application_id || activity.platform); - - for (const activity of applications) { - const { assets, application_id, platform } = activity; - if (!application_id && !platform) { - continue; - } - if (assets) { - - const addImage = (image: string, alt: string) => { - if (image.startsWith("mp:")) { - const discordMediaLink = `https://media.discordapp.net/${image.replace(/mp:/, "")}`; - if (settings.store.renderGifs || !discordMediaLink.endsWith(".gif")) { - applicationIcons.push({ - image: { src: discordMediaLink, alt }, - activity - }); - } - } else { - const src = `https://cdn.discordapp.com/app-assets/${application_id}/${image}.png`; - applicationIcons.push({ - image: { src, alt }, - activity - }); - } - }; - - // Prefer large image - const largeImage = assets.large_image; - if (largeImage) { - addImage(largeImage, assets.large_text ?? "Large Text"); - } else { - const smallImage = assets.small_image; - if (smallImage) { - addImage(smallImage, assets.small_text ?? "Small Text"); - } - } - } else if (application_id) { - let application = ApplicationStore.getApplication(application_id); - if (!application) { - if (fetchedApplications.has(application_id)) { - application = fetchedApplications.get(application_id) as Application | null; - } else { - fetchedApplications.set(application_id, null); - fetchApplication(application_id).then(app => { - fetchedApplications.set(application_id, app); - }); - } - } - - if (application) { - if (application.icon) { - const src = `https://cdn.discordapp.com/app-icons/${application.id}/${application.icon}.png`; - applicationIcons.push({ - image: { src, alt: application.name }, - activity - }); - } else if (platform === "xbox") { - applicationIcons.push({ - image: { src: xboxUrl, alt: "Xbox" }, - activity - }); - } - } - } else { - if (platform === "xbox") { - applicationIcons.push({ - image: { src: xboxUrl, alt: "Xbox" }, - activity - }); - } - } - } - - return applicationIcons; -} - -export default definePlugin({ - name: "MemberListActivities", - description: "Shows activity icons in the member list", - authors: [Devs.D3SOX], - tags: ["activity"], - - settings, - - patchActivityList: (activities: Activity[]): JSX.Element | null => { - const icons: ActivityListIcon[] = []; - - const spotifyActivity = activities.find(({ name }) => name === "Spotify"); - if (spotifyActivity) { - icons.push({ iconElement: , tooltip: spotifyActivity.details ?? spotifyActivity.name }); - } - const twitchActivity = activities.find(({ name }) => name === "Twitch"); - if (twitchActivity) { - icons.push({ iconElement: , tooltip: twitchActivity.details ?? twitchActivity.name }); - } - - const applicationIcons = getApplicationIcons(activities); - if (applicationIcons.length) { - const compareImageSource = (a: ApplicationIcon, b: ApplicationIcon) => { - return a.image.src === b.image.src; - }; - const uniqueIcons = applicationIcons.filter((element, index, array) => { - return array.findIndex(el => compareImageSource(el, element)) === index; - }); - for (const appIcon of uniqueIcons) { - icons.push({ - iconElement: , - tooltip: appIcon.activity.details ?? appIcon.activity.name - }); - } - } - - if (icons.length) { - return -
- {icons.map(({ iconElement, tooltip }, i) => { - return ( -
- {tooltip ? - {({ onMouseEnter, onMouseLeave }) => ( -
- {iconElement} -
- )} -
: iconElement} -
- ); - })} -
-
; - } else { - // Show default icon when there are no custom icons - // We need to filter out custom statuses - const shouldShow = activities.filter(a => a.type !== 4).length !== icons.length; - if (shouldShow) { - return ; - } - } - - return null; - }, - - patches: [ - { - // Patch activity icons - find: "default.getHangStatusActivity():null!", - replacement: { - match: /null!=(\i)&&\i.some\(\i=>\(0,\i.default\)\(\i,\i\)\)\?/, - replace: "$self.patchActivityList($1),false?" - } - }, - ], -}); diff --git a/src/plugins/memberListActivites/styles.css b/src/plugins/memberListActivites/styles.css deleted file mode 100644 index bb17b042..00000000 --- a/src/plugins/memberListActivites/styles.css +++ /dev/null @@ -1,20 +0,0 @@ -.vc-mla-row { - display: flex; - flex-wrap: nowrap; - align-items: center; - margin-left: 5px; - text-align: center; - gap: 3px; -} - -.vc-mla-icon { - height: 20px; - width: 20px; -} - -.vc-mla-icon img { - width: 100%; - height: 100%; - object-fit: cover; - border-radius: 50%; -} \ No newline at end of file