mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 18:06:22 +00:00
chore(betterActivities): remove unused code
This commit is contained in:
parent
4a95c367e3
commit
811397de3c
1 changed files with 1 additions and 48 deletions
|
@ -5,10 +5,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||||
import { moment } from "@webpack/common";
|
|
||||||
|
|
||||||
import settings from "./settings";
|
import settings from "./settings";
|
||||||
import { Activity, Application, ApplicationIcon, Timestamp } from "./types";
|
import { Activity, Application, ApplicationIcon } from "./types";
|
||||||
|
|
||||||
const ApplicationStore: {
|
const ApplicationStore: {
|
||||||
getApplication: (id: string) => Application | null;
|
getApplication: (id: string) => Application | null;
|
||||||
|
@ -18,27 +17,6 @@ const { fetchApplication }: {
|
||||||
fetchApplication: (id: string) => Promise<Application | null>;
|
fetchApplication: (id: string) => Promise<Application | null>;
|
||||||
} = findByPropsLazy("fetchApplication");
|
} = findByPropsLazy("fetchApplication");
|
||||||
|
|
||||||
export function getActivityImage(activity: Activity, application?: Application): string | undefined {
|
|
||||||
if (activity.type === 2 && activity.name === "Spotify") {
|
|
||||||
// get either from large or small image
|
|
||||||
const image = activity.assets?.large_image ?? activity.assets?.small_image;
|
|
||||||
// image needs to replace 'spotify:'
|
|
||||||
if (image?.startsWith("spotify:")) {
|
|
||||||
// spotify cover art is always https://i.scdn.co/image/ID
|
|
||||||
return image.replace("spotify:", "https://i.scdn.co/image/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (activity.type === 1 && activity.name === "Twitch") {
|
|
||||||
const image = activity.assets?.large_image;
|
|
||||||
// image needs to replace 'twitch:'
|
|
||||||
if (image?.startsWith("twitch:")) {
|
|
||||||
// twitch images are always https://static-cdn.jtvnw.net/previews-ttv/live_user_USERNAME-RESOLUTION.jpg
|
|
||||||
return `${image.replace("twitch:", "https://static-cdn.jtvnw.net/previews-ttv/live_user_")}-108x60.jpg`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO: we could support other assets here
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchedApplications = new Map<string, Application | null>();
|
const fetchedApplications = new Map<string, Application | null>();
|
||||||
|
|
||||||
// TODO: replace with "renderXboxImage"?
|
// TODO: replace with "renderXboxImage"?
|
||||||
|
@ -133,28 +111,3 @@ export function getApplicationIcons(activities: Activity[], preferSmall = false)
|
||||||
|
|
||||||
return applicationIcons;
|
return applicationIcons;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getValidTimestamps(activity: Activity): Required<Timestamp> | null {
|
|
||||||
if (activity.timestamps?.start !== undefined && activity.timestamps?.end !== undefined) {
|
|
||||||
return activity.timestamps as Required<Timestamp>;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getValidStartTimeStamp(activity: Activity): number | null {
|
|
||||||
if (activity.timestamps?.start !== undefined) {
|
|
||||||
return activity.timestamps.start;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const customFormat = (momentObj: moment.Moment): string => {
|
|
||||||
const hours = momentObj.hours();
|
|
||||||
const formattedTime = momentObj.format("mm:ss");
|
|
||||||
return hours > 0 ? `${momentObj.format("HH:")}${formattedTime}` : formattedTime;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function formatElapsedTime(startTime: moment.Moment, endTime: moment.Moment): string {
|
|
||||||
const duration = moment.duration(endTime.diff(startTime));
|
|
||||||
return `${customFormat(moment.utc(duration.asMilliseconds()))} elapsed`;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue