From 77a3b6c96c7959e4d16c4f276ccde9b880c58463 Mon Sep 17 00:00:00 2001 From: D3SOX Date: Mon, 18 Mar 2024 18:03:36 +0100 Subject: [PATCH] feat(memberListActivities): show default icon when no icons where found --- src/plugins/memberListActivities/index.tsx | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/plugins/memberListActivities/index.tsx b/src/plugins/memberListActivities/index.tsx index 3929f23a7..f24c131f1 100644 --- a/src/plugins/memberListActivities/index.tsx +++ b/src/plugins/memberListActivities/index.tsx @@ -23,7 +23,7 @@ import { classNameFactory } from "@api/Styles"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy, findStoreLazy } from "@webpack"; +import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack"; import { SpotifyIcon } from "./components/SpotifyIcon"; import { TwitchIcon } from "./components/TwitchIcon"; @@ -48,8 +48,13 @@ interface Activity { created_at: number; id: string; name: string; - state: string; type: number; + emoji?: { + animated: boolean; + id: string; + name: string; + } + state?: string; flags?: number; sync_id?: string; details?: string; @@ -100,6 +105,9 @@ 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"; @@ -112,7 +120,7 @@ export default definePlugin({ settings, - patchActivityList: (activities: Activity[]) => { + patchActivityList: (activities: Activity[]): JSX.Element | null => { const icons: JSX.Element[] = []; if (activities.some(activity => activity.name === "Spotify")) { @@ -197,9 +205,16 @@ export default definePlugin({ ))} ; + } 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 false; + return null; }, patches: [