* feat(SongSpotlight): port from vencord PR * feat(SongSpotlight): some slight code improvements * fix(components): match Link's props with vencord * fix(SongSpotlight): ditch React.memo & csp
29 lines
982 B
TypeScript
29 lines
982 B
TypeScript
/*
|
|
* Vencord, a Discord client mod
|
|
* Copyright (c) 2026 Vendicated and contributors
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
import { RenderSongInfo } from "@song-spotlight/api/handlers";
|
|
import type { Song } from "@song-spotlight/api/structs";
|
|
import { classNameFactory } from "@utils/css";
|
|
import { Logger } from "@utils/Logger";
|
|
|
|
export const logger = new Logger("SongSpotlight");
|
|
|
|
export const cl = classNameFactory("vc-songspotlight-");
|
|
|
|
export function formatDurationMs(duration: number) {
|
|
const seconds = Math.floor(duration / 1000);
|
|
return `${Math.floor(seconds / 60)}:${(seconds % 60).toString().padStart(2, "0")}`;
|
|
}
|
|
|
|
export function formatCoverTooltip(song: Song, render: RenderSongInfo) {
|
|
if (["user", "artist"].includes(song.type)) {
|
|
// "Jane Remover's Top tracks"
|
|
return `${render.label}'s ${render.sublabel}`;
|
|
} else {
|
|
// "Star people by Jane Remover"
|
|
return `${render.label} by ${render.sublabel}`;
|
|
}
|
|
}
|