mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
refactor(memberListActivities): move types to their own file
This commit is contained in:
parent
04cf952fe3
commit
c0f97446b8
2 changed files with 81 additions and 73 deletions
|
@ -24,12 +24,12 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
|
||||||
import { Tooltip, useMemo } from "@webpack/common";
|
import { React, Tooltip, useMemo } from "@webpack/common";
|
||||||
import { User } from "discord-types/general";
|
import { User } from "discord-types/general";
|
||||||
import type { ImgHTMLAttributes } from "react";
|
|
||||||
|
|
||||||
import { SpotifyIcon } from "./components/SpotifyIcon";
|
import { SpotifyIcon } from "./components/SpotifyIcon";
|
||||||
import { TwitchIcon } from "./components/TwitchIcon";
|
import { TwitchIcon } from "./components/TwitchIcon";
|
||||||
|
import { Activity, ActivityListIcon, Application, ApplicationIcon, Timestamp } from "./types";
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
iconSize: {
|
iconSize: {
|
||||||
|
@ -47,78 +47,8 @@ const settings = definePluginSettings({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface Timestamp {
|
|
||||||
start?: number;
|
|
||||||
end?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
timestamps?: Timestamp;
|
|
||||||
platform?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cl = classNameFactory("vc-mla-");
|
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<HTMLImageElement> & {
|
|
||||||
src: string;
|
|
||||||
alt: string;
|
|
||||||
};
|
|
||||||
activity: Activity;
|
|
||||||
application?: Application;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ActivityListIcon {
|
|
||||||
iconElement: JSX.Element;
|
|
||||||
tooltip?: JSX.Element | string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApplicationStore: {
|
const ApplicationStore: {
|
||||||
getApplication: (id: string) => Application | null;
|
getApplication: (id: string) => Application | null;
|
||||||
} = findStoreLazy("ApplicationStore");
|
} = findStoreLazy("ApplicationStore");
|
||||||
|
@ -296,7 +226,6 @@ export default definePlugin({
|
||||||
tooltip: <ActivityTooltip activity={spotifyActivity} />
|
tooltip: <ActivityTooltip activity={spotifyActivity} />
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const twitchActivity = activities.find(({ name }) => name === "Twitch");
|
const twitchActivity = activities.find(({ name }) => name === "Twitch");
|
||||||
if (twitchActivity) {
|
if (twitchActivity) {
|
||||||
icons.push({
|
icons.push({
|
||||||
|
@ -304,6 +233,7 @@ export default definePlugin({
|
||||||
tooltip: <ActivityTooltip activity={twitchActivity} />
|
tooltip: <ActivityTooltip activity={twitchActivity} />
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicationIcons = getApplicationIcons(activities);
|
const applicationIcons = getApplicationIcons(activities);
|
||||||
if (applicationIcons.length) {
|
if (applicationIcons.length) {
|
||||||
const compareImageSource = (a: ApplicationIcon, b: ApplicationIcon) => {
|
const compareImageSource = (a: ApplicationIcon, b: ApplicationIcon) => {
|
||||||
|
|
78
src/plugins/memberListActivities/types.ts
Normal file
78
src/plugins/memberListActivities/types.ts
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { ImgHTMLAttributes } from "react";
|
||||||
|
|
||||||
|
export interface Timestamp {
|
||||||
|
start?: number;
|
||||||
|
end?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export 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;
|
||||||
|
};
|
||||||
|
timestamps?: Timestamp;
|
||||||
|
platform?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Developer {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Executable {
|
||||||
|
os: string;
|
||||||
|
name: string;
|
||||||
|
is_launcher: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApplicationIcon {
|
||||||
|
image: ImgHTMLAttributes<HTMLImageElement> & {
|
||||||
|
src: string;
|
||||||
|
alt: string;
|
||||||
|
};
|
||||||
|
activity: Activity;
|
||||||
|
application?: Application;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActivityListIcon {
|
||||||
|
iconElement: JSX.Element;
|
||||||
|
tooltip?: JSX.Element | string;
|
||||||
|
}
|
Loading…
Reference in a new issue