From 7989e81e6cb02974c55a5c4dd4ca29eda84be996 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:17:59 -0400 Subject: [PATCH] Revert "Remove ThemeLibrary Download Button Temp" This reverts commit e49f3de2aa6ac1b446480d24a4af2ca108507286. --- .../components/ThemeInfoModal.tsx | 78 ++++++++++++++++++- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx b/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx index 1d8fb233..5954c06e 100644 --- a/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx +++ b/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx @@ -9,17 +9,29 @@ import { Heart } from "@components/Heart"; import { copyToClipboard } from "@utils/clipboard"; import { openInviteModal } from "@utils/discord"; import { Margins } from "@utils/margins"; +import { classes } from "@utils/misc"; import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import type { PluginNative } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; import { Button, Forms, Parser, React, showToast, Toasts } from "@webpack/common"; -import { ThemeInfoModalProps } from "../types"; -import { ClockIcon, WarningIcon } from "../utils/Icons"; +import { Theme, ThemeInfoModalProps } from "../types"; +import { ClockIcon, DownloadIcon, WarningIcon } from "../utils/Icons"; +import { logger } from "./ThemeTab"; const Native = VencordNative.pluginHelpers.ThemeLibrary as PluginNative; const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers"); +async function downloadTheme(themesDir: string, theme: Theme) { + try { + await Native.downloadTheme(themesDir, theme); + showToast(`Downloaded ${theme.name}!`, Toasts.Type.SUCCESS); + } catch (err: unknown) { + logger.error(err); + showToast(`Failed to download ${theme.name}! (check console)`, Toasts.Type.FAILURE); + } +} + export const ThemeInfoModal: React.FC = ({ author, theme, ...props }) => { const { type, content, likes, guild, tags, last_updated, requiresThemeAttributes } = theme; @@ -177,6 +189,68 @@ export const ThemeInfoModal: React.FC = ({ author, theme, . > Close + + + + + )); + } else { + await downloadTheme(themesDir, theme); + } + }} + > +
+ Download +
+ );