mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-11 02:16:23 +00:00
feat(memberListActivities): show default icon when no icons where found
This commit is contained in:
parent
896421a9fa
commit
77a3b6c96c
1 changed files with 19 additions and 4 deletions
|
@ -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<Application | null>;
|
||||
} = 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<string, Application | null>();
|
||||
|
||||
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({
|
|||
))}
|
||||
</div>
|
||||
</ErrorBoundary>;
|
||||
} 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 <DefaultActivityIcon />;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
},
|
||||
|
||||
patches: [
|
||||
|
|
Loading…
Reference in a new issue