/* * Vencord, a Discord client mod * Copyright (c) 2023 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { BaseText } from "@components/BaseText"; import { Flex } from "@components/Flex"; import { HeadingPrimary } from "@components/Heading"; import { CopyIcon } from "@components/Icons"; import { AvatarStyles, cl, downloadAudio, getEmojiUrl, playSound, SoundLogEntry, User, UserSummaryItem } from "@equicordplugins/soundBoardLogger/utils"; import { copyWithToast, openUserProfile } from "@utils/discord"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { closeModal, ModalContent, ModalRoot, openModal } from "@utils/modal"; import { Clickable, Timestamp } from "@webpack/common"; import moment from "moment"; import { DownloadIcon, IconWithTooltip, PlayIcon } from "./Icons"; export function openUserModal(item, user, sounds) { const key = openModal(props => closeModal(key)} /> ); } export default function UserModal({ item, user, sounds, closeModal }: { item: SoundLogEntry, user: User, sounds: SoundLogEntry[], closeModal: Function; }) { const currentUser = item.users.find(({ id }) => id === user.id) ?? { id: "", plays: [0] }; const soundsDoneByCurrentUser = sounds.filter(sound => sound.users.some(itemUser => itemUser.id === user.id) && sound.soundId !== item.soundId); return ( { closeModal(); openUserProfile(user.id); }}>
{user.username}
{item.soundId} Played {currentUser.plays.length} {currentUser.plays.length === 1 ? "time" : "times"}. Last played: {soundsDoneByCurrentUser.length ? "Also played:" : " "}
...
} className={cl("user-sounds")} renderUser={({ soundId, emoji }) => ( { closeModal(); openUserModal(sounds.find(sound => sound.soundId === soundId), user, sounds); }} > {soundId} )} />
} onClick={() => downloadAudio(item.soundId)} /> } onClick={() => copyWithToast(item.soundId, "ID copied to clipboard!")} /> } onClick={() => playSound(item.soundId)} />
); }