/* * Vencord, a Discord client mod * Copyright (c) 2024 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import { getCurrentChannel } from "@utils/discord"; import { makeLazy } from "@utils/lazy"; import definePlugin from "@utils/types"; import { filters, find, findByPropsLazy, handleModuleNotFound } from "@webpack"; import { React, RelationshipStore } from "@webpack/common"; const { Heading, Text } = findByPropsLazy("Heading", "Text"); // Workaround for module differing on stable & canary // FIXME: remove once merged into stable const getMemberSinceContainer = makeLazy(() => { for (const name of ["memberSinceWrapper", "memberSinceContainer"]) { const mod = find(filters.byProps(name), { isIndirect: true }); if (mod) return mod[name]; } handleModuleNotFound("findByProps", "memberSinceWrapper/memberSinceContainer"); return ""; }); const { getCreatedAtDate } = findByPropsLazy("getCreatedAtDate"); const clydeMoreInfo = findByPropsLazy("clydeMoreInfo"); const locale = findByPropsLazy("getLocale"); const lastSection = findByPropsLazy("lastSection"); export default definePlugin({ name: "FriendsSince", description: "Shows when you became friends with someone in the user popout", authors: [Devs.Elvyra], patches: [ { find: ".AnalyticsSections.USER_PROFILE}", replacement: { match: /\i.default,\{userId:(\i.id).{0,30}}\)/, replace: "$&,$self.friendsSince({ userId: $1 })" } }, { find: ".UserPopoutUpsellSource.PROFILE_PANEL,", replacement: { match: /\i.default,\{userId:(\i)}\)/, replace: "$&,$self.friendsSince({ userId: $1 })" } } ], friendsSince: ErrorBoundary.wrap(({ userId }: { userId: string; }) => { const friendsSince = RelationshipStore.getSince(userId); if (!friendsSince) return null; return (
Friends Since
{!!getCurrentChannel()?.guild_id && ( )} {getCreatedAtDate(friendsSince, locale.getLocale())}
); }, { noop: true }) });