From 1693273f8ba45e31d6a8c5330f22f943b33f364c Mon Sep 17 00:00:00 2001 From: sadan <117494111+sadan4@users.noreply.github.com> Date: Sun, 26 Jan 2025 22:58:42 -0500 Subject: [PATCH] make copyWithToast use error style on error --- src/utils/misc.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 28c371c5b..ef6eff92c 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import { Clipboard, Toasts } from "@webpack/common"; +import { Clipboard, ToastData, Toasts } from "@webpack/common"; import { DevsById } from "./constants"; @@ -36,15 +36,19 @@ export function sleep(ms: number): Promise { } export function copyWithToast(text: string, toastMessage = "Copied to clipboard!") { + const opts: Pick = { + message: toastMessage, + type: Toasts.Type.SUCCESS + }; if (Clipboard.SUPPORTS_COPY) { Clipboard.copy(text); } else { - toastMessage = "Your browser does not support copying to clipboard"; + opts.message = "Your browser does not support copying to clipboard"; + opts.type = Toasts.Type.FAILURE; } Toasts.show({ - message: toastMessage, id: Toasts.genId(), - type: Toasts.Type.SUCCESS + ...opts }); }