From e68a69641c793dd9a10451dbee405bff1e246f07 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Sat, 3 Oct 2026 11:16:17 -0400 Subject: [PATCH] Fixes --- .../settings/tabs/changelog/index.tsx | 71 +++++----------- .../settings/tabs/plugins/PluginModal.tsx | 14 ++-- .../settings/tabs/plugins/index.tsx | 14 ++-- src/components/settings/tabs/themes/index.tsx | 8 +- .../settings/tabs/updater/Components.tsx | 13 +-- .../betterAudioPlayer/index.tsx | 4 +- .../betterImageEditor/index.tsx | 22 ++--- src/equicordplugins/channelTabs/util/tabs.tsx | 8 +- .../UploadClipFileModal.tsx | 4 +- .../clipUpload.desktop/upload.ts | 10 +-- .../commandPalette/commands/custom.tsx | 6 +- .../commands/discordActions.tsx | 6 +- .../commandPalette/commands/openSettings.ts | 6 +- .../commands/pluginManagement.tsx | 14 ++-- .../commandPalette/commands/sendDm.tsx | 4 +- .../copyProfileColors/index.tsx | 20 +---- src/equicordplugins/copyStatusUrls/index.ts | 25 ++---- .../downloadAllAttachments/index.tsx | 6 +- src/equicordplugins/dragify/index.tsx | 4 +- src/equicordplugins/dragify/invite.ts | 10 +-- src/equicordplugins/equicordHelper/index.tsx | 4 +- .../equicordHelper/pluginButtons.tsx | 6 +- src/equicordplugins/equicordHelper/utils.tsx | 14 ++-- src/equicordplugins/exitSounds/index.tsx | 8 +- src/equicordplugins/exportMessages/index.tsx | 25 ++---- .../favouriteAnything/utils.tsx | 6 +- src/equicordplugins/fileUpload/index.tsx | 6 +- src/equicordplugins/fileUpload/settings.tsx | 10 +-- .../fileUpload/utils/upload.ts | 32 +++---- src/equicordplugins/findReply/index.tsx | 20 +---- .../components/contextMenus.tsx | 10 +-- .../gifCollections/utils/collectionManager.ts | 7 +- .../gifCollections/utils/settingsUtils.ts | 14 +--- src/equicordplugins/globalBadges/index.tsx | 8 +- .../instantScreenshare/index.tsx | 4 +- src/equicordplugins/jumpTo/index.tsx | 14 +--- .../keyboardNavigation/commands.tsx | 69 +++++---------- src/equicordplugins/lastActive/index.tsx | 26 ++---- .../components/ClearLogsButton.tsx | 14 +--- .../components/FolderSelectInput.tsx | 14 +--- .../messageLoggerEnhanced/db.ts | 12 +-- .../messageLoggerEnhanced/index.tsx | 4 +- .../utils/contextMenu.tsx | 8 +- .../utils/settingsUtils.ts | 38 ++------- .../moreStickers/components/misc.tsx | 83 +++++-------------- .../moreStickers/migrate-v1.ts | 38 ++------- src/equicordplugins/moreStickers/upload.ts | 4 +- .../musicControls/settings.tsx | 10 +-- src/equicordplugins/orbolayBridge/index.tsx | 14 +--- .../profileSets/utils/actions.ts | 4 +- .../questify/utils/completion.ts | 6 +- .../index.tsx | 8 +- src/equicordplugins/randomVoice/index.tsx | 18 ++-- .../recentDMSwitcher/index.tsx | 16 +--- .../components/ScheduleTimeModal.tsx | 4 +- .../components/ViewScheduledModal.tsx | 6 +- .../scheduledMessages/utils.ts | 6 +- .../showMessageEmbeds/index.tsx | 5 +- .../songSpotlight.desktop/lib/api.ts | 8 +- .../songSpotlight.desktop/lib/oauth2.tsx | 6 +- .../ui/components/AudioPlayer.tsx | 4 +- .../ui/settings/index.tsx | 16 ++-- .../ui/songs/CollapsedProfileSongs.tsx | 8 +- .../songSpotlight.desktop/ui/songs/index.tsx | 18 +--- .../splitLargeMessages/index.ts | 14 +--- src/equicordplugins/statusPresets/index.tsx | 8 +- .../streaks/stores/AuthorizationStore.tsx | 4 +- .../components/ThemeInfoModal.tsx | 10 +-- .../themeLibrary/utils/auth.tsx | 14 ++-- .../themeLibrary/utils/settings.tsx | 25 ++---- src/equicordplugins/timezones/database.tsx | 10 +-- src/equicordplugins/timezones/index.tsx | 15 ++-- src/equicordplugins/triviaAI/utils.ts | 8 +- src/equicordplugins/userpfp/AvatarModal.tsx | 8 +- .../components/SettingsTab.tsx | 8 +- .../whitelistedEmojis/index.tsx | 22 ++--- src/plugins/_core/supportHelper.tsx | 6 +- src/plugins/customRPC/RpcSettings.tsx | 8 +- src/plugins/devCompanion.dev/initWs.tsx | 36 +++----- src/plugins/devCompanion.dev/util.tsx | 25 ++---- src/plugins/favEmojiFirst/index.tsx | 32 ++----- src/plugins/messageClickActions/index.ts | 11 +-- 82 files changed, 403 insertions(+), 785 deletions(-) diff --git a/src/components/settings/tabs/changelog/index.tsx b/src/components/settings/tabs/changelog/index.tsx index c630700e9..b8e162181 100644 --- a/src/components/settings/tabs/changelog/index.tsx +++ b/src/components/settings/tabs/changelog/index.tsx @@ -19,7 +19,8 @@ import { HashLink } from "@components/settings/tabs/updater/Components"; import { Margins } from "@utils/margins"; import { useAwaiter } from "@utils/react"; import { getRepo, UpdateLogger } from "@utils/updater"; -import { Alerts, React, Toasts } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { Alerts, React, showToast } from "@webpack/common"; import gitHash from "~git-hash"; @@ -352,14 +353,9 @@ function ChangelogContent() { const logged = await ensureLocalUpdateLogged(); if (!logged) { setChangelog([]); - Toasts.show({ - message: "Already up to date with repository", - id: Toasts.genId(), - type: Toasts.Type.MESSAGE, - options: { - position: Toasts.Position.BOTTOM, - }, - }); + showToast("Already up to date with repository", "message", { + position: ToastPosition.BOTTOM, + }); } return; } @@ -384,27 +380,17 @@ function ChangelogContent() { await loadChangelogHistory(); setRecentlyChecked(true); - Toasts.show({ - message: `Found ${updates.value.length} commit${updates.value.length === 1 ? "" : "s"} from repository`, - id: Toasts.genId(), - type: Toasts.Type.SUCCESS, - options: { - position: Toasts.Position.BOTTOM, - }, - }); + showToast(`Found ${updates.value.length} commit${updates.value.length === 1 ? "" : "s"} from repository`, "success", { + position: ToastPosition.BOTTOM, + }); } else { const logged = await ensureLocalUpdateLogged(); setRecentlyChecked(true); - Toasts.show({ - message: logged + showToast(logged ? "Logged commits from your latest update" - : "Repository is up to date with your local copy", - id: Toasts.genId(), - type: logged ? Toasts.Type.SUCCESS : Toasts.Type.MESSAGE, - options: { - position: Toasts.Position.BOTTOM, - }, - }); + : "Repository is up to date with your local copy", logged ? "success" : "message", { + position: ToastPosition.BOTTOM, + }); if (!logged) { setChangelog([]); } @@ -422,14 +408,9 @@ function ChangelogContent() { setError(errorMessage); // funny little error toast hopefully doesn't happen! - Toasts.show({ - message: "Could not fetch commits from repository", - id: Toasts.genId(), - type: Toasts.Type.FAILURE, - options: { - position: Toasts.Position.BOTTOM, - }, - }); + showToast("Could not fetch commits from repository", "failure", { + position: ToastPosition.BOTTOM, + }); } finally { setIsLoading(false); } @@ -520,14 +501,9 @@ function ChangelogContent() { await clearChangelogHistory(); await loadChangelogHistory(); setShowHistory(false); - Toasts.show({ - message: "All logs have been cleared", - id: Toasts.genId(), - type: Toasts.Type.SUCCESS, - options: { - position: Toasts.Position.BOTTOM, - }, - }); + showToast("All logs have been cleared", "success", { + position: ToastPosition.BOTTOM, + }); }, }); }} @@ -659,14 +635,9 @@ function ChangelogContent() { Array.from(expandedLogs).filter(id => id !== logId), ), ); - Toasts.show({ - message: "Log has been cleared", - id: Toasts.genId(), - type: Toasts.Type.SUCCESS, - options: { - position: Toasts.Position.BOTTOM, - }, - }); + showToast("Log has been cleared", "success", { + position: ToastPosition.BOTTOM, + }); }, }); }} diff --git a/src/components/settings/tabs/plugins/PluginModal.tsx b/src/components/settings/tabs/plugins/PluginModal.tsx index 2feb27a93..a3edefd82 100644 --- a/src/components/settings/tabs/plugins/PluginModal.tsx +++ b/src/components/settings/tabs/plugins/PluginModal.tsx @@ -34,8 +34,9 @@ import { Margins } from "@utils/margins"; import { classes, isObjectEmpty } from "@utils/misc"; import { OptionType, Plugin, PluginTag } from "@utils/types"; import { RenderModalProps, User } from "@vencord/discord-types"; +import { ToastPosition } from "@vencord/discord-types/enums"; import { findComponentByCodeLazy, findCssClassesLazy } from "@webpack"; -import { Clickable, FluxDispatcher, Modal, openModal, React, Text, Toasts, Tooltip, useEffect, useMemo, UserStore, UserSummaryItem, UserUtils, useState } from "@webpack/common"; +import { Clickable, FluxDispatcher, Modal, openModal, React, showToast,Text, Tooltip, useEffect, useMemo, UserStore, UserSummaryItem, UserUtils, useState } from "@webpack/common"; import { Constructor } from "type-fest"; import { PluginMeta } from "~plugins"; @@ -324,14 +325,9 @@ function resetSettings(plugin: Plugin, onRestartNeeded?: (pluginName: string) => onRestartNeeded?.(plugin.name); } - Toasts.show({ - message: `Settings for ${pluginName} have been reset.`, - id: Toasts.genId(), - type: Toasts.Type.SUCCESS, - options: { - position: Toasts.Position.TOP - } - }); + showToast(`Settings for ${pluginName} have been reset.`, "success", { + position: ToastPosition.TOP + }); } export function openWarningModal(plugin?: Plugin | null, onRestartNeeded?: (pluginName: string) => void, isPlugin = true, enabledPlugins?: number | null, reset?: () => void) { diff --git a/src/components/settings/tabs/plugins/index.tsx b/src/components/settings/tabs/plugins/index.tsx index 917092096..469f7669b 100644 --- a/src/components/settings/tabs/plugins/index.tsx +++ b/src/components/settings/tabs/plugins/index.tsx @@ -38,7 +38,8 @@ import { classes } from "@utils/misc"; import { PluginTarget } from "@utils/pluginTargets"; import { useAwaiter, useCleanupEffect, useIntersection } from "@utils/react"; import { PluginTag, PluginTags } from "@utils/types"; -import { Alerts, ConfirmModal, lodash, openModal, Parser, React, SearchableSelect, Select, TextInput, Toasts, Tooltip, useCallback, useMemo, useRef, useState } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { Alerts, ConfirmModal, lodash, openModal, Parser, React, SearchableSelect, Select, showToast,TextInput, Tooltip, useCallback, useMemo, useRef, useState } from "@webpack/common"; import { JSX } from "react"; import Plugins, { ExcludedPlugins, PluginMeta } from "~plugins"; @@ -52,14 +53,9 @@ export const cl = classNameFactory("vc-plugins-"); export const logger = new Logger("PluginSettings", "#a6d189"); function showErrorToast(message: string) { - Toasts.show({ - message, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast(message, "failure", { + position: ToastPosition.BOTTOM + }); } function ReloadRequiredCard({ required, enabledPlugins, openWarningModal, resetCheckAndDo }) { diff --git a/src/components/settings/tabs/themes/index.tsx b/src/components/settings/tabs/themes/index.tsx index 81ce6d728..dc392ca95 100644 --- a/src/components/settings/tabs/themes/index.tsx +++ b/src/components/settings/tabs/themes/index.tsx @@ -18,7 +18,7 @@ import { copyWithToast } from "@utils/discord"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; import { getStylusWebStoreUrl } from "@utils/web"; -import { React, Select, showToast, TextInput, Toasts, useEffect, useMemo, useRef, useState } from "@webpack/common"; +import { React, Select, showToast, TextInput, useEffect, useMemo, useRef, useState } from "@webpack/common"; import { SyntheticEvent } from "react"; import { OnlineThemesSection } from "./OnlineThemes"; @@ -263,9 +263,9 @@ function ThemesTab() { setOnlineThemes(prev => prev?.map(t => t.link === link ? updatedTheme : t) ?? null ); - showToast("Theme refreshed!", Toasts.Type.SUCCESS); + showToast("Theme refreshed!", "success"); } catch { - showToast("Failed to refresh theme", Toasts.Type.FAILURE); + showToast("Failed to refresh theme", "failure"); } } @@ -288,7 +288,7 @@ function ThemesTab() { URL.revokeObjectURL(url); } } catch { - showToast("Failed to download theme", Toasts.Type.FAILURE); + showToast("Failed to download theme", "failure"); } } diff --git a/src/components/settings/tabs/updater/Components.tsx b/src/components/settings/tabs/updater/Components.tsx index 783c7fd1d..29cade515 100644 --- a/src/components/settings/tabs/updater/Components.tsx +++ b/src/components/settings/tabs/updater/Components.tsx @@ -15,7 +15,7 @@ import { Margins } from "@utils/margins"; import { relaunch } from "@utils/native"; import { changes, checkForUpdates, update, updateError } from "@utils/updater"; import { ToastPosition } from "@vencord/discord-types/enums"; -import { ConfirmModal, openModal, React, showToast, Toasts, useState } from "@webpack/common"; +import { ConfirmModal, openModal, React, showToast, useState } from "@webpack/common"; import { runWithDispatch } from "./runWithDispatch"; @@ -91,14 +91,9 @@ export function Updatable(props: CommonProps) { } else { setUpdates([]); - Toasts.show({ - message: "No updates found!", - id: Toasts.genId(), - type: Toasts.Type.MESSAGE, - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast("No updates found!", "message", { + position: ToastPosition.BOTTOM + }); } })} > diff --git a/src/equicordplugins/betterAudioPlayer/index.tsx b/src/equicordplugins/betterAudioPlayer/index.tsx index 8361c3043..19da0092e 100644 --- a/src/equicordplugins/betterAudioPlayer/index.tsx +++ b/src/equicordplugins/betterAudioPlayer/index.tsx @@ -10,7 +10,7 @@ import { definePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin, { OptionType } from "@utils/types"; -import { ColorUtils, React, showToast, Toasts } from "@webpack/common"; +import { ColorUtils, React, showToast } from "@webpack/common"; const cl = classNameFactory("vc-better-audio-player-"); const CORS_PROXY = "https://cors.keiran0.workers.dev?url="; @@ -39,7 +39,7 @@ function validateColor(value: string, key: string, fallback: string) { } } catch { /* invalid hex */ } - showToast(`Invalid color format for ${key}, use "R, G, B" or "#RRGGBB"`, Toasts.Type.FAILURE); + showToast(`Invalid color format for ${key}, use "R, G, B" or "#RRGGBB"`, "failure"); settings.store[key] = fallback; } diff --git a/src/equicordplugins/betterImageEditor/index.tsx b/src/equicordplugins/betterImageEditor/index.tsx index 6dc94ac03..98147235c 100644 --- a/src/equicordplugins/betterImageEditor/index.tsx +++ b/src/equicordplugins/betterImageEditor/index.tsx @@ -13,7 +13,7 @@ import { Logger } from "@utils/Logger"; import { classes, pluralise } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; import { chooseFile, saveFile } from "@utils/web"; -import { Alerts, Button, React, showToast, Toasts, useCallback, useEffect, useRef, useState } from "@webpack/common"; +import { Alerts, Button, React, showToast, useCallback, useEffect, useRef, useState } from "@webpack/common"; import { cl, croppedLabel, Shelf } from "./components/Shelf"; import { add, clear, CropState, currentApplied, Entry, exportAll, forget, forgetCrops, getFile, getThumbs, Group, importAll, Kind, previousApplied, readIndex, recordApplied, saveCrop, toDataUrl, togglePin, touch } from "./library"; @@ -86,7 +86,7 @@ const settings = definePluginSettings({ onConfirm: () => forgetCrops() .then(count => showToast( count ? `Forgot the framing on ${pluralise(count, "picture")}` : "Nothing was framed", - Toasts.Type.SUCCESS + "success" )) .catch(err => logger.error("could not forget the remembered crops", err)) })} @@ -165,7 +165,7 @@ async function exportLibrary() { else saveFile(new File([data], FILENAME, { type: "application/json" })); } catch (err) { logger.error("could not export the library", err); - showToast("Could not export your pictures", Toasts.Type.FAILURE); + showToast("Could not export your pictures", "failure"); } } @@ -186,11 +186,11 @@ async function importLibrary() { const added = await importAll(json, settings.store.librarySize); showToast( added ? `Added ${pluralise(added, "picture")}` : "Nothing new in that file", - Toasts.Type.SUCCESS + "success" ); } catch (err) { logger.error("could not import the library", err); - showToast("Could not read that file", Toasts.Type.FAILURE); + showToast("Could not read that file", "failure"); } } @@ -324,7 +324,7 @@ function PickerShelf({ kind, open, complete, maxSize }: { const onPick = useCallback(async (entry: Entry) => { const blob = await getFile(entry.id); - if (!blob) return showToast("That picture is missing", Toasts.Type.FAILURE); + if (!blob) return showToast("That picture is missing", "failure"); const file = new File([blob], entry.name, { type: blob.type }); await touch(entry.id); @@ -344,7 +344,7 @@ function PickerShelf({ kind, open, complete, maxSize }: { }, [bump]); const accept = useCallback(async (file: File) => { - if (maxSize && file.size > maxSize) return showToast("That picture is too big for Discord", Toasts.Type.FAILURE); + if (maxSize && file.size > maxSize) return showToast("That picture is too big for Discord", "failure"); try { const entry = await add(file, kind, "original", settings.store.librarySize); @@ -352,7 +352,7 @@ function PickerShelf({ kind, open, complete, maxSize }: { await hand(entry.id, file, settings.store.rememberCrop ? entry.crop ?? null : null); } catch (err) { logger.error("could not take that picture", err); - showToast("Could not use that picture", Toasts.Type.FAILURE); + showToast("Could not use that picture", "failure"); } }, [kind, hand, bump, maxSize]); @@ -432,7 +432,7 @@ function EditorShelf({ Original, ownProps }: { Original: React.ComponentType { const blob = await getFile(entry.id); - if (!blob) return showToast("That picture is missing", Toasts.Type.FAILURE); + if (!blob) return showToast("That picture is missing", "failure"); await touch(entry.id); bump(); @@ -464,7 +464,7 @@ function EditorShelf({ Original, ownProps }: { Original: React.ComponentType save().catch(err => { logger.error("could not keep the cropped copy", err); - showToast("Could not keep the cropped copy", Toasts.Type.FAILURE); + showToast("Could not keep the cropped copy", "failure"); }); if (!settings.store.askBeforeSavingCropped) return void run(); diff --git a/src/equicordplugins/channelTabs/util/tabs.tsx b/src/equicordplugins/channelTabs/util/tabs.tsx index 209e371c4..ea77c7df6 100644 --- a/src/equicordplugins/channelTabs/util/tabs.tsx +++ b/src/equicordplugins/channelTabs/util/tabs.tsx @@ -7,7 +7,7 @@ import { DataStore } from "@api/index"; import { isPluginEnabled } from "@api/PluginManager"; import { classNameFactory } from "@utils/css"; -import { NavigationRouter, SelectedChannelStore, SelectedGuildStore, showToast, Toasts, useEffect, useRef, useState } from "@webpack/common"; +import { NavigationRouter, SelectedChannelStore, SelectedGuildStore, showToast, useEffect, useRef, useState } from "@webpack/common"; import { JSX } from "react"; import { logger, settings } from "./constants"; @@ -418,7 +418,7 @@ export async function openStartupTabs(props: BasicChannelTabsProps & { userId: s savedTabs = persistedTabs?.[userId]; } catch (error) { logger.error("Failed to load persisted tabs from DataStore", error); - showToast("Failed to load saved tabs", Toasts.Type.FAILURE); + showToast("Failed to load saved tabs", "failure"); } } @@ -430,14 +430,14 @@ export async function openStartupTabs(props: BasicChannelTabsProps & { userId: s if (keepCurrentChannel) { hydratedUserId = undefined; - showToast("Not restoring tabs as KeepCurrentChannel is enabled", Toasts.Type.FAILURE); + showToast("Not restoring tabs as KeepCurrentChannel is enabled", "failure"); return; } switch (settings.store.onStartup) { case "remember": { if (!savedTabs?.openTabs.length) { - showToast("Failed to restore tabs", Toasts.Type.FAILURE); + showToast("Failed to restore tabs", "failure"); break; } diff --git a/src/equicordplugins/clipUpload.desktop/UploadClipFileModal.tsx b/src/equicordplugins/clipUpload.desktop/UploadClipFileModal.tsx index f5552c7bc..31fe0d2fa 100644 --- a/src/equicordplugins/clipUpload.desktop/UploadClipFileModal.tsx +++ b/src/equicordplugins/clipUpload.desktop/UploadClipFileModal.tsx @@ -9,7 +9,7 @@ import { Flex } from "@components/Flex"; import { Heading } from "@components/Heading"; import { Paragraph } from "@components/Paragraph"; import type { RenderModalProps } from "@vencord/discord-types"; -import { Checkbox, FluxDispatcher, MessageActions, Modal, openModal, PendingReplyStore, showToast, Toasts, useEffect, useState } from "@webpack/common"; +import { Checkbox, FluxDispatcher, MessageActions, Modal, openModal, PendingReplyStore, showToast, useEffect, useState } from "@webpack/common"; import { ApplicationField, BooleanField, DateTimeField, getDateTimeLocalValue, ParticipantField, TextField } from "./fields"; import { abortActiveClipUploads, type ClipMetadata, getClipCreatedAt, getClipTitleFromName, getDefaultClipTitle, getDefaultFileName, getErrorMessage, getParticipantIds, getString, isValidDate, pickClipFile, uploadClipFile } from "./upload"; @@ -52,7 +52,7 @@ function UploadClipFileModal({ modalProps, channelId, clip }: { modalProps: Rend result = await pickClipFile(parseMetadata); if (!result) return; } catch (error) { - showToast(getErrorMessage(error), Toasts.Type.FAILURE); + showToast(getErrorMessage(error), "failure"); return; } diff --git a/src/equicordplugins/clipUpload.desktop/upload.ts b/src/equicordplugins/clipUpload.desktop/upload.ts index b93fdef02..c1f6c4fae 100644 --- a/src/equicordplugins/clipUpload.desktop/upload.ts +++ b/src/equicordplugins/clipUpload.desktop/upload.ts @@ -8,7 +8,7 @@ import { Logger } from "@utils/Logger"; import { isObject } from "@utils/misc"; import type { PluginNative } from "@utils/types"; import type { User } from "@vencord/discord-types"; -import { Constants, MediaEngineStore, RestAPI, showToast, SnowflakeUtils, Toasts } from "@webpack/common"; +import { Constants, MediaEngineStore, RestAPI, showToast, SnowflakeUtils } from "@webpack/common"; import { convertClipToMp4 } from "./ffmpeg"; const logger = new Logger("ClipUpload"); @@ -329,7 +329,7 @@ function shouldRetryWithFFmpeg(error: unknown) { export async function uploadClipFile(file: File, options: ClipUploadOptions) { try { - showToast("Checking clip file.", Toasts.Type.MESSAGE); + showToast("Checking clip file.", "message"); const uploadFile = await prepareClipFile(file, options.fileName); @@ -338,15 +338,15 @@ export async function uploadClipFile(file: File, options: ClipUploadOptions) { } catch (error) { if (!shouldRetryWithFFmpeg(error)) throw error; - showToast("Converting clip file.", Toasts.Type.MESSAGE); + showToast("Converting clip file.", "message"); await sendClipUpload(await stampVideoFile(await convertClipToMp4(file, options.fileName), options.fileName), options); } - showToast("Clip uploaded.", Toasts.Type.SUCCESS); + showToast("Clip uploaded.", "success"); return true; } catch (error) { logger.error(error); - showToast(getErrorMessage(error), Toasts.Type.FAILURE); + showToast(getErrorMessage(error), "failure"); return false; } } diff --git a/src/equicordplugins/commandPalette/commands/custom.tsx b/src/equicordplugins/commandPalette/commands/custom.tsx index 50c98efc3..2a6b1dd8f 100644 --- a/src/equicordplugins/commandPalette/commands/custom.tsx +++ b/src/equicordplugins/commandPalette/commands/custom.tsx @@ -6,7 +6,7 @@ import { insertTextIntoChatInputBox } from "@utils/discord"; import { parseUrl } from "@utils/misc"; -import { showToast, Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; import { registerCommands } from "../api/registry"; import type { FormPageSpec, PageEntry, PaletteAction, PaletteCommand } from "../api/types"; @@ -109,7 +109,7 @@ function commandForm(existing: CustomCommandData | null): PageEntry { : [...store.get(), next]); registerCustomCommands(); - showToast(existing ? "Command saved." : "Command created.", Toasts.Type.SUCCESS); + showToast(existing ? "Command saved." : "Command created.", "success"); ctx.pop(); } }; @@ -138,7 +138,7 @@ function toCommand(data: CustomCommandData): PaletteCommand { run() { store.set(store.get().filter(entry => entry.id !== data.id)); registerCustomCommands(); - showToast("Command deleted.", Toasts.Type.SUCCESS); + showToast("Command deleted.", "success"); } } ]; diff --git a/src/equicordplugins/commandPalette/commands/discordActions.tsx b/src/equicordplugins/commandPalette/commands/discordActions.tsx index ebafcda2f..24db2ed80 100644 --- a/src/equicordplugins/commandPalette/commands/discordActions.tsx +++ b/src/equicordplugins/commandPalette/commands/discordActions.tsx @@ -7,7 +7,7 @@ import { getUserSettingLazy } from "@api/UserSettings"; import type { Theme } from "@vencord/discord-types"; import { findByCodeLazy } from "@webpack"; -import { showToast, ThemeStore, Toasts, VoiceActions } from "@webpack/common"; +import { showToast, ThemeStore, VoiceActions } from "@webpack/common"; import type { PaletteCommand } from "../api/types"; import { CircleIcon, HeadphonesIcon, MicIcon, MoonIcon } from "../ui/icons"; @@ -78,7 +78,7 @@ export const discordCommands: PaletteCommand[] = [ label: `Set ${status.label}`, run() { StatusSetting?.updateSetting(status.value); - showToast(`Status set to ${status.label}.`, Toasts.Type.SUCCESS); + showToast(`Status set to ${status.label}.`, "success"); } }] })) @@ -98,7 +98,7 @@ export const discordCommands: PaletteCommand[] = [ const currentIdx = THEMES.findIndex(theme => theme.value === ThemeStore.theme); const next = THEMES[(currentIdx + 1) % THEMES.length]; updateDiscordTheme({ theme: next.value }); - showToast(`Theme set to ${next.label}.`, Toasts.Type.SUCCESS); + showToast(`Theme set to ${next.label}.`, "success"); } }] } diff --git a/src/equicordplugins/commandPalette/commands/openSettings.ts b/src/equicordplugins/commandPalette/commands/openSettings.ts index 12d4365dd..6fc4196fc 100644 --- a/src/equicordplugins/commandPalette/commands/openSettings.ts +++ b/src/equicordplugins/commandPalette/commands/openSettings.ts @@ -5,7 +5,7 @@ */ import { Logger } from "@utils/Logger"; -import { SettingsRouter, showToast, Toasts } from "@webpack/common"; +import { SettingsRouter, showToast } from "@webpack/common"; export interface SettingsRoute { route: string; @@ -110,7 +110,7 @@ const logger = new Logger("CommandPalette"); export async function openSettingsPage(route: string, label?: string) { const candidates = resolveRouteCandidates(route); if (candidates.length === 0) { - showToast("No settings page was provided.", Toasts.Type.FAILURE); + showToast("No settings page was provided.", "failure"); return false; } @@ -124,6 +124,6 @@ export async function openSettingsPage(route: string, label?: string) { } } - showToast(`Unable to open ${label ?? "that settings page"}.`, Toasts.Type.FAILURE); + showToast(`Unable to open ${label ?? "that settings page"}.`, "failure"); return false; } diff --git a/src/equicordplugins/commandPalette/commands/pluginManagement.tsx b/src/equicordplugins/commandPalette/commands/pluginManagement.tsx index 01e9e6da3..677a66470 100644 --- a/src/equicordplugins/commandPalette/commands/pluginManagement.tsx +++ b/src/equicordplugins/commandPalette/commands/pluginManagement.tsx @@ -8,7 +8,7 @@ import { isPluginEnabled, pluginRequiresRestart, plugins, startDependenciesRecur import { Settings } from "@api/Settings"; import { openPluginModal } from "@components/settings/tabs/plugins/PluginModal"; import type { Plugin } from "@utils/types"; -import { showToast, Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; import type { PaletteCommand, PaletteListItem } from "../api/types"; import { GearIcon, PlugIcon } from "../ui/icons"; @@ -20,37 +20,37 @@ function togglePlugin(plugin: Plugin) { if (!wasEnabled) { const { restartNeeded, failures } = startDependenciesRecursive(plugin); if (failures.length) { - showToast(`Failed to start dependencies: ${failures.join(", ")}`, Toasts.Type.FAILURE); + showToast(`Failed to start dependencies: ${failures.join(", ")}`, "failure"); return; } if (restartNeeded) { pluginSettings.enabled = true; - showToast(`${plugin.name} enabled. Restart to apply.`, Toasts.Type.MESSAGE); + showToast(`${plugin.name} enabled. Restart to apply.`, "message"); return; } } if (pluginRequiresRestart(plugin)) { pluginSettings.enabled = !wasEnabled; - showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}. Restart to apply.`, Toasts.Type.MESSAGE); + showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}. Restart to apply.`, "message"); return; } if (wasEnabled && !plugin.started) { pluginSettings.enabled = false; - showToast(`${plugin.name} disabled.`, Toasts.Type.SUCCESS); + showToast(`${plugin.name} disabled.`, "success"); return; } const result = wasEnabled ? stopPlugin(plugin) : startPlugin(plugin); if (!result) { pluginSettings.enabled = false; - showToast(`Error while ${wasEnabled ? "stopping" : "starting"} ${plugin.name}.`, Toasts.Type.FAILURE); + showToast(`Error while ${wasEnabled ? "stopping" : "starting"} ${plugin.name}.`, "failure"); return; } pluginSettings.enabled = !wasEnabled; - showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}.`, Toasts.Type.SUCCESS); + showToast(`${plugin.name} ${wasEnabled ? "disabled" : "enabled"}.`, "success"); } function pluginItems(): PaletteListItem[] { diff --git a/src/equicordplugins/commandPalette/commands/sendDm.tsx b/src/equicordplugins/commandPalette/commands/sendDm.tsx index d049eba4b..d1155f2d3 100644 --- a/src/equicordplugins/commandPalette/commands/sendDm.tsx +++ b/src/equicordplugins/commandPalette/commands/sendDm.tsx @@ -7,7 +7,7 @@ import { openPrivateChannel, sendMessage } from "@utils/discord"; import { sleep } from "@utils/misc"; import { CloudUploadPlatform } from "@vencord/discord-types/enums"; -import { ChannelStore, CloudUploader, IconUtils, RelationshipStore, showToast, Toasts, UserStore } from "@webpack/common"; +import { ChannelStore, CloudUploader, IconUtils, RelationshipStore, showToast, UserStore } from "@webpack/common"; import type { FormFieldOption, FormSubmitExtras, PaletteCommand } from "../api/types"; import { fuzzyScore } from "../search/ranker"; @@ -82,7 +82,7 @@ export const sendDmCommand: PaletteCommand = { }); const user = UserStore.getUser(values.recipient); - showToast(`Message sent to ${user.globalName || user.username}.`, Toasts.Type.SUCCESS); + showToast(`Message sent to ${user.globalName || user.username}.`, "success"); ctx.close(); } } diff --git a/src/equicordplugins/copyProfileColors/index.tsx b/src/equicordplugins/copyProfileColors/index.tsx index ecb94eefd..c70a21487 100644 --- a/src/equicordplugins/copyProfileColors/index.tsx +++ b/src/equicordplugins/copyProfileColors/index.tsx @@ -10,7 +10,7 @@ import { EquicordDevs } from "@utils/constants"; import { Logger } from "@utils/Logger"; import definePlugin from "@utils/types"; import { User } from "@vencord/discord-types"; -import { Menu, SelectedGuildStore, Toasts, UserProfileStore } from "@webpack/common"; +import { Menu, SelectedGuildStore, showToast,UserProfileStore } from "@webpack/common"; const logger = new Logger("CopyProfileColors"); @@ -38,11 +38,7 @@ function copyProfileColors(userId: string, guildId?: string) { const colors = getProfileColors(userId, guildId); if (!colors) { - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "No profile colors found!", - id: Toasts.genId() - }); + showToast("No profile colors found!", "failure"); return; } @@ -53,18 +49,10 @@ function copyProfileColors(userId: string, guildId?: string) { try { copyToClipboard(formattedColors); - Toasts.show({ - type: Toasts.Type.SUCCESS, - message: "Profile colors copied to clipboard!", - id: Toasts.genId() - }); + showToast("Profile colors copied to clipboard!", "success"); } catch (e) { logger.error("Failed to copy to clipboard:", e); - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "Error copying profile colors!", - id: Toasts.genId() - }); + showToast("Error copying profile colors!", "failure"); } } diff --git a/src/equicordplugins/copyStatusUrls/index.ts b/src/equicordplugins/copyStatusUrls/index.ts index ff17bb6f0..67efcf17b 100644 --- a/src/equicordplugins/copyStatusUrls/index.ts +++ b/src/equicordplugins/copyStatusUrls/index.ts @@ -8,8 +8,9 @@ import { copyToClipboard } from "@utils/clipboard"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { User } from "@vencord/discord-types"; +import { ToastPosition } from "@vencord/discord-types/enums"; import { findByCodeLazy } from "@webpack"; -import { Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; interface MakeContextMenuProps { user: User, @@ -44,24 +45,14 @@ export default definePlugin({ throw new Error("button_urls does not contain index"); } copyToClipboard(button_urls[index]); - Toasts.show({ - id: Toasts.genId(), - message: "Copied URL", - type: Toasts.Type.SUCCESS, - options: { - position: Toasts.Position.TOP - } - }); + showToast("Copied URL", "success", { + position: ToastPosition.TOP + }); } catch (e) { console.error(e); - Toasts.show({ - id: Toasts.genId(), - message: "Error copying URL, check console for more info", - type: Toasts.Type.FAILURE, - options: { - position: Toasts.Position.TOP - } - }); + showToast("Error copying URL, check console for more info", "failure", { + position: ToastPosition.TOP + }); } }; } diff --git a/src/equicordplugins/downloadAllAttachments/index.tsx b/src/equicordplugins/downloadAllAttachments/index.tsx index d08c1cb3e..bc6f441e8 100644 --- a/src/equicordplugins/downloadAllAttachments/index.tsx +++ b/src/equicordplugins/downloadAllAttachments/index.tsx @@ -11,7 +11,7 @@ import { Logger } from "@utils/Logger"; import { pluralize } from "@utils/misc"; import definePlugin, { OptionType } from "@utils/types"; import { Message, MessageAttachment } from "@vencord/discord-types"; -import { ChannelStore, showToast, Toasts } from "@webpack/common"; +import { ChannelStore, showToast } from "@webpack/common"; const logger = new Logger("DownloadAllAttachments"); @@ -71,9 +71,9 @@ async function downloadAll(attachments: MessageAttachment[]) { const succeeded = attachments.length - failed; if (failed === 0) - showToast(`Downloaded ${pluralize(succeeded, "attachment")}.`, Toasts.Type.SUCCESS); + showToast(`Downloaded ${pluralize(succeeded, "attachment")}.`, "success"); else - showToast(`Downloaded ${succeeded} of ${attachments.length} attachments. ${failed} failed.`, Toasts.Type.FAILURE); + showToast(`Downloaded ${succeeded} of ${attachments.length} attachments. ${failed} failed.`, "failure"); } export default definePlugin({ diff --git a/src/equicordplugins/dragify/index.tsx b/src/equicordplugins/dragify/index.tsx index 34d37ade3..83cc51a7c 100644 --- a/src/equicordplugins/dragify/index.tsx +++ b/src/equicordplugins/dragify/index.tsx @@ -13,7 +13,7 @@ import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import type { Channel } from "@vencord/discord-types"; import { ChannelType } from "@vencord/discord-types/enums"; -import { ChannelStore, GuildStore, IconUtils, RelationshipStore, SelectedChannelStore, showToast, Toasts, UserStore } from "@webpack/common"; +import { ChannelStore, GuildStore, IconUtils, RelationshipStore, SelectedChannelStore, showToast, UserStore } from "@webpack/common"; import { beginDrag as beginSessionDrag, clearDragState, getLastDropAt, hasActiveDrag, isGuildDragActive, isInputDragSource, isUserDragActive, markDrop, markInputDragSource, scheduleGuildCleanup, shouldIgnoreDrop, startDragWatchdog, stopDragState, touchDrag } from "./dragState"; import { type GhostState, hideGhost as hideDragGhost, isGhostVisible, mountGhost as mountDragGhost, scheduleGhostPosition as scheduleDragGhostPosition, showGhost as showDragGhost, unmountGhost as unmountDragGhost } from "./ghost"; @@ -293,7 +293,7 @@ export default definePlugin({ } catch (error) { clearDragState(); logger.error("Failed handling drop", error); - showToast("Dragify failed to handle drop.", Toasts.Type.FAILURE); + showToast("Dragify failed to handle drop.", "failure"); } }, diff --git a/src/equicordplugins/dragify/invite.ts b/src/equicordplugins/dragify/invite.ts index 66bfce9ac..ad8e2be3e 100644 --- a/src/equicordplugins/dragify/invite.ts +++ b/src/equicordplugins/dragify/invite.ts @@ -7,7 +7,7 @@ import { Logger } from "@utils/Logger"; import type { Channel } from "@vencord/discord-types"; import { ChannelType } from "@vencord/discord-types/enums"; -import { ChannelStore, GuildChannelStore, GuildStore, PermissionsBits, PermissionStore, RestAPI, showToast, Toasts } from "@webpack/common"; +import { ChannelStore, GuildChannelStore, GuildStore, PermissionsBits, PermissionStore, RestAPI, showToast } from "@webpack/common"; const logger = new Logger("Dragify"); @@ -135,7 +135,7 @@ function getInviteUrl(code: string) { export async function createInvite(guildId: string, currentChannel: Channel, settings: InviteSettings): Promise { const inviteChannel = resolveInviteChannel(guildId, currentChannel); if (!inviteChannel) { - showToast("No channel available for invites.", Toasts.Type.FAILURE); + showToast("No channel available for invites.", "failure"); return null; } @@ -147,7 +147,7 @@ export async function createInvite(guildId: string, currentChannel: Channel, set reused.reason === "missing" ? "No reusable invite available." : "Unable to reuse invite.", - Toasts.Type.FAILURE, + "failure", ); return null; } @@ -174,11 +174,11 @@ export async function createInvite(guildId: string, currentChannel: Channel, set maxUses: maxUses === 0 ? null : maxUses, uses: 0, }); - showToast("Invite created.", Toasts.Type.SUCCESS); + showToast("Invite created.", "success"); return getInviteUrl(code); } catch (error) { logger.error("Failed to create invite", error); - showToast("Unable to create invite.", Toasts.Type.FAILURE); + showToast("Unable to create invite.", "failure"); return null; } } diff --git a/src/equicordplugins/equicordHelper/index.tsx b/src/equicordplugins/equicordHelper/index.tsx index ce3dd7b18..6361de8c1 100644 --- a/src/equicordplugins/equicordHelper/index.tsx +++ b/src/equicordplugins/equicordHelper/index.tsx @@ -314,7 +314,7 @@ export default definePlugin({ match: /case \i\.\i\.WINDOWS:/, replace: 'case "WEB":' }, - predicate: () => Settings.winNativeTitleBar, + predicate: () => Settings.nativeTitleBar, }, { find: '"refresh-title-bar-small"', @@ -328,7 +328,7 @@ export default definePlugin({ replace: "true" } ], - predicate: () => Settings.winNativeTitleBar, + predicate: () => Settings.nativeTitleBar, }, { find: "DirectMessage: getSpringConfigs()", diff --git a/src/equicordplugins/equicordHelper/pluginButtons.tsx b/src/equicordplugins/equicordHelper/pluginButtons.tsx index 759c60ca5..4cd7da35a 100644 --- a/src/equicordplugins/equicordHelper/pluginButtons.tsx +++ b/src/equicordplugins/equicordHelper/pluginButtons.tsx @@ -9,7 +9,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Logger } from "@utils/Logger"; import { isEquicordGuild, isEquicordSupport } from "@utils/misc"; import { Message } from "@vencord/discord-types"; -import { Button, showToast, Toasts } from "@webpack/common"; +import { Button, showToast } from "@webpack/common"; import { JSX } from "react"; import { toggleEnabled } from "./utils"; @@ -50,10 +50,10 @@ export const PluginButtons = ErrorBoundary.wrap(function PluginCards({ message } onClick={async () => { try { const success = await toggleEnabled(matchedPlugin); - if (success) showToast(`${label}`, Toasts.Type.SUCCESS); + if (success) showToast(`${label}`, "success"); } catch (e) { new Logger("EquicordHelper").error("Error while toggling:", e); - showToast(`Failed to ${label.toLowerCase()}`, Toasts.Type.FAILURE); + showToast(`Failed to ${label.toLowerCase()}`, "failure"); } }} > diff --git a/src/equicordplugins/equicordHelper/utils.tsx b/src/equicordplugins/equicordHelper/utils.tsx index a8ab59b93..382a2dd72 100644 --- a/src/equicordplugins/equicordHelper/utils.tsx +++ b/src/equicordplugins/equicordHelper/utils.tsx @@ -7,17 +7,13 @@ import { showNotice } from "@api/Notices"; import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager"; import { Settings } from "@api/Settings"; -import { Alerts, Toasts } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { Alerts, showToast } from "@webpack/common"; function showErrorToast(message: string) { - Toasts.show({ - message, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast(message, "failure", { + position: ToastPosition.BOTTOM + }); } function restartPrompt(): Promise { diff --git a/src/equicordplugins/exitSounds/index.tsx b/src/equicordplugins/exitSounds/index.tsx index 8e9fe8d1f..d81e9f5a2 100644 --- a/src/equicordplugins/exitSounds/index.tsx +++ b/src/equicordplugins/exitSounds/index.tsx @@ -14,7 +14,7 @@ import { Devs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import definePlugin, { OptionType } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; -import { Constants, GuildStore, IconUtils, MediaEngineStore, Menu, RestAPI, SearchableSelect, SelectedChannelStore, TextInput, Toasts } from "@webpack/common"; +import { Constants, GuildStore, IconUtils, MediaEngineStore, Menu, RestAPI, SearchableSelect, SelectedChannelStore, showToast,TextInput } from "@webpack/common"; const cl = classNameFactory("vc-exitsounds-"); @@ -134,11 +134,7 @@ export default definePlugin({ } }); } catch { - Toasts.show({ - message: "Oops! Something went wrong.", - id: Toasts.genId(), - type: Toasts.Type.FAILURE - }); + showToast("Oops! Something went wrong.", "failure"); } } }); diff --git a/src/equicordplugins/exportMessages/index.tsx b/src/equicordplugins/exportMessages/index.tsx index d7f0e5ff2..1647add55 100644 --- a/src/equicordplugins/exportMessages/index.tsx +++ b/src/equicordplugins/exportMessages/index.tsx @@ -15,7 +15,8 @@ import { showItemInFolder } from "@utils/native"; import definePlugin, { OptionType } from "@utils/types"; import { saveFile } from "@utils/web"; import { Message } from "@vencord/discord-types"; -import { Menu, Toasts } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { Menu, showToast } from "@webpack/common"; import { ContactsList } from "./types"; @@ -175,28 +176,18 @@ export default definePlugin({ copyContactToClipboard() { if (this.contactList) { copyToClipboard(JSON.stringify(this.contactList)); - Toasts.show({ - message: "Contacts copied to clipboard successfully.", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { + showToast("Contacts copied to clipboard successfully.", "success", { duration: 3000, - position: Toasts.Position.BOTTOM - } - }); + position: ToastPosition.BOTTOM + }); return; } // reason why you need to click the all tab is because the data is extracted during // the request itself when you fetch all your friends. this is done to avoid sending a // manual request to discord, which may raise suspicion and might even get you terminated. - Toasts.show({ - message: "Contact list is undefined. Click on the \"All\" tab before exporting.", - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { + showToast("Contact list is undefined. Click on the \"All\" tab before exporting.", "failure", { duration: 3000, - position: Toasts.Position.BOTTOM - } - }); + position: ToastPosition.BOTTOM + }); } }); diff --git a/src/equicordplugins/favouriteAnything/utils.tsx b/src/equicordplugins/favouriteAnything/utils.tsx index 72282e06b..9f86d7b84 100644 --- a/src/equicordplugins/favouriteAnything/utils.tsx +++ b/src/equicordplugins/favouriteAnything/utils.tsx @@ -12,7 +12,7 @@ import { useForceUpdater } from "@utils/react"; import { PluginNative } from "@utils/types"; import { Channel, MessageAttachment } from "@vencord/discord-types"; import { findByCodeLazy, findByPropsLazy } from "@webpack"; -import { Constants, createRoot, DraftType, FluxDispatcher, Humanize, MessageActions, PendingReplyStore, PermissionStore, ReactDOM, RestAPI, Toasts, UploadAttachmentStore, UploadHandler, UploadManager, useCallback, useEffect, useRef, UserSettingsActionCreators, UserSettingsProtoStore, useStateFromStores } from "@webpack/common"; +import { Constants, createRoot, DraftType, FluxDispatcher, Humanize, MessageActions, PendingReplyStore, PermissionStore, ReactDOM, RestAPI, showToast,UploadAttachmentStore, UploadHandler, UploadManager, useCallback, useEffect, useRef, UserSettingsActionCreators, UserSettingsProtoStore, useStateFromStores } from "@webpack/common"; import { deflateSync, inflateSync } from "fflate"; import { Key, ReactNode } from "react"; import { JsonValue } from "type-fest"; @@ -189,13 +189,13 @@ async function fetchAttachment(attachment: MessageAttachment): Promise { export async function sendAttachment(attachment: MessageAttachment, channel: Channel) { const { filename, title, description } = attachment; const file = await fetchAttachment(attachment).catch(() => - Toasts.show({ message: `Couldn't fetch ${filename}`, id: Toasts.genId(), type: Toasts.Type.FAILURE }) + showToast(`Couldn't fetch ${filename}`, "failure") ); if (!file) return; // Using promptToUpload instead of addFiles directly since it has file size checks with error popups await UploadHandler.promptToUpload([file], channel, DraftType.ChannelMessage).catch(() => - Toasts.show({ message: `Couldn't upload ${filename}`, id: Toasts.genId(), type: Toasts.Type.FAILURE }) + showToast(`Couldn't upload ${filename}`, "failure") ); const uploads = [...UploadAttachmentStore.getUploads(channel.id, DraftType.ChannelMessage)]; diff --git a/src/equicordplugins/fileUpload/index.tsx b/src/equicordplugins/fileUpload/index.tsx index ab4c39a1c..b356c08e1 100644 --- a/src/equicordplugins/fileUpload/index.tsx +++ b/src/equicordplugins/fileUpload/index.tsx @@ -14,7 +14,7 @@ import { classNameFactory } from "@utils/css"; import definePlugin from "@utils/types"; import { CloudUpload } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; -import { DraftType, FluxDispatcher, Menu, PermissionsBits, PermissionStore, React, showToast, Toasts, UploadAttachmentStore, useEffect, UserStore, useState } from "@webpack/common"; +import { DraftType, FluxDispatcher, Menu, PermissionsBits, PermissionStore, React, showToast, UploadAttachmentStore, useEffect, UserStore, useState } from "@webpack/common"; import { settings } from "./settings"; import { serviceLabels, ServiceType } from "./types"; @@ -233,12 +233,12 @@ async function handleUploadFileFromDraft(upload: CloudUpload) { if (!file) return; if (!isFileTypeAllowed(file)) { - showToast("File type not allowed by current filter", Toasts.Type.FAILURE); + showToast("File type not allowed by current filter", "failure"); return; } if (!isConfigured()) { - showToast("Please configure FileUpload settings first", Toasts.Type.FAILURE); + showToast("Please configure FileUpload settings first", "failure"); return; } diff --git a/src/equicordplugins/fileUpload/settings.tsx b/src/equicordplugins/fileUpload/settings.tsx index 74643650e..a3457f34e 100644 --- a/src/equicordplugins/fileUpload/settings.tsx +++ b/src/equicordplugins/fileUpload/settings.tsx @@ -11,7 +11,7 @@ import { Switch } from "@components/Switch"; import { classNameFactory } from "@utils/css"; import { useForceUpdater } from "@utils/react"; import { OptionType } from "@utils/types"; -import { React, Select, showToast, TextArea, TextInput, Toasts } from "@webpack/common"; +import { React, Select, showToast, TextArea, TextInput } from "@webpack/common"; import { CORS_PROXY } from "./constants"; import { fallbackServiceOrder, serviceLabels, ServiceType } from "./types"; @@ -520,10 +520,10 @@ export function SettingsComponent() { const validateShareXConfig = () => { try { parseShareXConfig(settings.store.sharexConfig || ""); - showToast("ShareX config is valid", Toasts.Type.SUCCESS); + showToast("ShareX config is valid", "success"); } catch (error) { const message = error instanceof Error ? error.message : "Invalid ShareX config"; - showToast(message, Toasts.Type.FAILURE); + showToast(message, "failure"); } }; @@ -542,10 +542,10 @@ export function SettingsComponent() { const parsed = parseShareXConfig(content); settings.store.sharexConfig = JSON.stringify(parsed, null, 2); update(); - showToast("Imported ShareX config", Toasts.Type.SUCCESS); + showToast("Imported ShareX config", "success"); } catch (error) { const message = error instanceof Error ? error.message : "Failed to import ShareX config"; - showToast(message, Toasts.Type.FAILURE); + showToast(message, "failure"); } }; reader.readAsText(file); diff --git a/src/equicordplugins/fileUpload/utils/upload.ts b/src/equicordplugins/fileUpload/utils/upload.ts index 94da98de4..a44d224e9 100644 --- a/src/equicordplugins/fileUpload/utils/upload.ts +++ b/src/equicordplugins/fileUpload/utils/upload.ts @@ -12,7 +12,7 @@ import { insertTextIntoChatInputBox } from "@utils/discord"; import { Logger } from "@utils/Logger"; import { PluginNative } from "@utils/types"; import { chooseFile } from "@utils/web"; -import { showToast, Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; import { convertApngToGif } from "./apngToGif"; import { getExtensionFromBytes, getExtensionFromMime, getMimeFromExtension, getUrlExtension } from "./getMediaUrl"; @@ -1304,19 +1304,19 @@ function getFilenameExtension(filename: string): string | undefined { async function notifyUploadSuccess(finalUrl: string, forceSend?: boolean): Promise { if (settings.store.autoCopy) { if (!finalUrl || !finalUrl.trim()) { - showToast("Upload successful, but no URL was available to copy", Toasts.Type.MESSAGE); + showToast("Upload successful, but no URL was available to copy", "message"); return; } try { await copyToClipboard(finalUrl); - showToast("Upload successful, URL copied to clipboard", Toasts.Type.SUCCESS); + showToast("Upload successful, URL copied to clipboard", "success"); } catch (error) { logger.warn("Upload succeeded but clipboard copy failed", error); - showToast("Upload successful, but failed to copy URL", Toasts.Type.MESSAGE); + showToast("Upload successful, but failed to copy URL", "message"); } } else { - showToast("Upload successful", Toasts.Type.SUCCESS); + showToast("Upload successful", "success"); } const autoSend = forceSend || Boolean((settings.store as { autoSend?: boolean; }).autoSend); @@ -1366,7 +1366,7 @@ async function uploadWithFallbacks(fileBlob: Blob, filename: string, primary: Se try { const uploadedUrl = await uploadToService(service, fileBlob, filename); if (attempted.length) { - showToast(`Upload succeeded with ${serviceLabels[service]} after fallback`, Toasts.Type.SUCCESS); + showToast(`Upload succeeded with ${serviceLabels[service]} after fallback`, "success"); } setUploadState({ @@ -1433,7 +1433,7 @@ async function normalizeUploadBlob(blob: Blob, sourceUrl?: string): Promise<{ bl blob = gifBlob; ext = "gif"; } else { - showToast("APNG to GIF conversion failed, uploading as APNG", Toasts.Type.FAILURE); + showToast("APNG to GIF conversion failed, uploading as APNG", "failure"); } } @@ -1463,12 +1463,12 @@ async function uploadPreparedBlob(blob: Blob, sourceUrl?: string, forceSend?: bo export async function uploadFile(url: string): Promise { if (isUploading) { - showToast("Upload already in progress", Toasts.Type.MESSAGE); + showToast("Upload already in progress", "message"); return; } if (!isConfigured()) { - showToast("Please configure FileUpload settings first", Toasts.Type.FAILURE); + showToast("Please configure FileUpload settings first", "failure"); return; } @@ -1527,10 +1527,10 @@ export async function uploadFile(url: string): Promise { } catch (error) { const message = error instanceof Error ? error.message : "Unknown error"; if (isUploadCancelledError(error)) { - showToast("Upload cancelled", Toasts.Type.MESSAGE); + showToast("Upload cancelled", "message"); setUploadState({ phase: "cancelled", status: "Upload cancelled.", canCancel: false, percent: 0 }); } else { - showToast(`Upload failed: ${message}`, Toasts.Type.FAILURE); + showToast(`Upload failed: ${message}`, "failure"); logger.error("Upload error", error); setUploadState({ phase: "failed", status: `Upload failed: ${message}`, canCancel: false, percent: 0 }); } @@ -1547,7 +1547,7 @@ export async function uploadPickedFile(): Promise { if (!file) return; if (!isFileTypeAllowed(file)) { - showToast("File type not allowed by current filter", Toasts.Type.FAILURE); + showToast("File type not allowed by current filter", "failure"); return; } @@ -1556,12 +1556,12 @@ export async function uploadPickedFile(): Promise { export async function uploadProvidedFiles(files: readonly File[], forceSend?: boolean): Promise { if (isUploading) { - showToast("Upload already in progress", Toasts.Type.MESSAGE); + showToast("Upload already in progress", "message"); return; } if (!isConfigured()) { - showToast("Please configure FileUpload settings first", Toasts.Type.FAILURE); + showToast("Please configure FileUpload settings first", "failure"); return; } @@ -1596,10 +1596,10 @@ export async function uploadProvidedFiles(files: readonly File[], forceSend?: bo } catch (error) { const message = error instanceof Error ? error.message : "Unknown error"; if (isUploadCancelledError(error)) { - showToast("Upload cancelled", Toasts.Type.MESSAGE); + showToast("Upload cancelled", "message"); setUploadState({ phase: "cancelled", status: "Upload cancelled.", canCancel: false, percent: 0 }); } else { - showToast(`Upload failed: ${message}`, Toasts.Type.FAILURE); + showToast(`Upload failed: ${message}`, "failure"); logger.error("Manual upload error", error); setUploadState({ phase: "failed", status: `Upload failed: ${message}`, canCancel: false, percent: 0 }); } diff --git a/src/equicordplugins/findReply/index.tsx b/src/equicordplugins/findReply/index.tsx index 33c28ba8f..6d7de3f64 100644 --- a/src/equicordplugins/findReply/index.tsx +++ b/src/equicordplugins/findReply/index.tsx @@ -22,7 +22,7 @@ import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Message } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; -import { ChannelStore, createRoot, MessageStore, Toasts } from "@webpack/common"; +import { ChannelStore, createRoot, MessageStore, showToast } from "@webpack/common"; import { Root } from "react-dom/client"; import ReplyNavigator from "./ReplyNavigator"; @@ -115,18 +115,10 @@ export default definePlugin({ jumpType: "INSTANT" }); if (replies.length > 1) { - Toasts.show({ - id: Toasts.genId(), - message: "Use the bottom panel to navigate between replies.", - type: Toasts.Type.MESSAGE - }); + showToast("Use the bottom panel to navigate between replies.", "message"); const container = document.querySelector("[class*=channelBottomBarArea_]"); if (!container) { - Toasts.show({ - id: Toasts.genId(), - message: "Couldn't find the container element.", - type: Toasts.Type.FAILURE - }); + showToast("Couldn't find the container element.", "failure"); return; } @@ -139,11 +131,7 @@ export default definePlugin({ root!.render(); } } else { - Toasts.show({ - id: Toasts.genId(), - message: "Couldn't find a reply.", - type: Toasts.Type.FAILURE - }); + showToast("Couldn't find a reply.", "failure"); } } }; diff --git a/src/equicordplugins/gifCollections/components/contextMenus.tsx b/src/equicordplugins/gifCollections/components/contextMenus.tsx index 9ebda0391..7bc7658fa 100644 --- a/src/equicordplugins/gifCollections/components/contextMenus.tsx +++ b/src/equicordplugins/gifCollections/components/contextMenus.tsx @@ -7,7 +7,7 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu"; import { FolderIcon, InfoIcon, LinkIcon, PencilIcon, PlusIcon, RemixIcon, TrashIcon } from "@components/Icons"; import { copyToClipboard } from "@utils/clipboard"; -import { Alerts, Button, FluxDispatcher, Menu, showToast, Toasts } from "@webpack/common"; +import { Alerts, Button, FluxDispatcher, Menu, showToast } from "@webpack/common"; import { settings } from "../settings"; import { Gif } from "../types"; @@ -71,7 +71,7 @@ export const addCollectionContextMenuPatch: NavContextMenuPatchCallback = (child leadingAccessory={{ type: "icon", icon: LinkIcon }} action={() => { copyToClipboard(gif.url); - showToast("Image link copied to clipboard", Toasts.Type.SUCCESS); + showToast("Image link copied to clipboard", "success"); }} /> ); @@ -131,7 +131,7 @@ export function RemoveItemContextMenuItems({ type, nameOrId }: { type: "collecti const gif = getGifById(nameOrId); if (!gif) return; copyToClipboard(gif.url); - showToast("URL copied to clipboard", Toasts.Type.SUCCESS); + showToast("URL copied to clipboard", "success"); }} /> { copyToClipboard(gif.url); - showToast("Image link copied to clipboard", Toasts.Type.SUCCESS); + showToast("Image link copied to clipboard", "success"); }} /> )} @@ -220,7 +220,7 @@ export function getGifPickerContextMenuItems(src: string, url: string, height: n leadingAccessory={{ type: "icon", icon: LinkIcon }} action={() => { copyToClipboard(url); - showToast("Image link copied to clipboard", Toasts.Type.SUCCESS); + showToast("Image link copied to clipboard", "success"); }} /> )} diff --git a/src/equicordplugins/gifCollections/utils/collectionManager.ts b/src/equicordplugins/gifCollections/utils/collectionManager.ts index eafcc839b..8aa138749 100644 --- a/src/equicordplugins/gifCollections/utils/collectionManager.ts +++ b/src/equicordplugins/gifCollections/utils/collectionManager.ts @@ -5,7 +5,8 @@ */ import { DataStore } from "@api/index"; -import { Toasts } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { showToast } from "@webpack/common"; import { settings } from "../settings"; import { Collection, Gif } from "../types"; @@ -32,7 +33,7 @@ export async function createCollection(name: string, gifs: Gif[]): Promise const fullName = `${settings.store.collectionPrefix}${name}`; if (collections.some(c => c.name === fullName)) { - Toasts.show({ message: "That collection already exists", type: Toasts.Type.FAILURE, id: Toasts.genId(), options: { duration: 3000, position: Toasts.Position.BOTTOM } }); + showToast("That collection already exists", "failure", { duration: 3000, position: ToastPosition.BOTTOM }); return; } @@ -56,7 +57,7 @@ export async function addToCollection(name: string, gif: Gif): Promise { if (!collection) return void logger.warn("Collection not found"); if (settings.store.preventDuplicates && collection.gifs.some(g => g.url === gif.url)) { - Toasts.show({ message: "This GIF is already in the collection", type: Toasts.Type.FAILURE, id: Toasts.genId(), options: { duration: 3000, position: Toasts.Position.BOTTOM } }); + showToast("This GIF is already in the collection", "failure", { duration: 3000, position: ToastPosition.BOTTOM }); return; } diff --git a/src/equicordplugins/gifCollections/utils/settingsUtils.ts b/src/equicordplugins/gifCollections/utils/settingsUtils.ts index d7f12fcc3..299328581 100644 --- a/src/equicordplugins/gifCollections/utils/settingsUtils.ts +++ b/src/equicordplugins/gifCollections/utils/settingsUtils.ts @@ -6,7 +6,7 @@ import { DataStore } from "@api/index"; import { chooseFile, saveFile } from "@utils/web"; -import { Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; import { DATA_COLLECTION_NAME, getCollections, refreshCacheCollection } from "./collectionManager"; import { logger } from "./misc"; @@ -70,14 +70,6 @@ export async function uploadGifCollections(showToast = true): Promise { } } -const toastSuccess = () => Toasts.show({ - type: Toasts.Type.SUCCESS, - message: "Collections imported successfully.", - id: Toasts.genId(), -}); +const toastSuccess = () => showToast("Collections imported successfully.", "success"); -const toastFailure = (err: unknown) => Toasts.show({ - type: Toasts.Type.FAILURE, - message: `Failed to import collections: ${String(err)}`, - id: Toasts.genId(), -}); +const toastFailure = (err: unknown) => showToast(`Failed to import collections: ${String(err)}`, "failure"); diff --git a/src/equicordplugins/globalBadges/index.tsx b/src/equicordplugins/globalBadges/index.tsx index bb57c6db9..341826220 100644 --- a/src/equicordplugins/globalBadges/index.tsx +++ b/src/equicordplugins/globalBadges/index.tsx @@ -12,7 +12,7 @@ import { BadgeContextMenu } from "@plugins/_api/badges"; import { Devs, EquicordDevs } from "@utils/constants"; import { openInviteModal } from "@utils/discord"; import definePlugin from "@utils/types"; -import { ContextMenuApi, React, Toasts } from "@webpack/common"; +import { ContextMenuApi, React, showToast } from "@webpack/common"; import { settings } from "./settings"; import { cl, GlobalBadges, INVITE_LINK, loadBadges } from "./utils"; @@ -47,11 +47,7 @@ export default definePlugin({ toolboxActions: { async "Refetch Global Badges"() { await loadBadges(); - Toasts.show({ - id: Toasts.genId(), - message: "Successfully refetched global badges!", - type: Toasts.Type.SUCCESS - }); + showToast("Successfully refetched global badges!", "success"); } }, get GlobalBadges() { diff --git a/src/equicordplugins/instantScreenshare/index.tsx b/src/equicordplugins/instantScreenshare/index.tsx index fa81ec5e7..f24fb7733 100644 --- a/src/equicordplugins/instantScreenshare/index.tsx +++ b/src/equicordplugins/instantScreenshare/index.tsx @@ -11,7 +11,7 @@ import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { VoiceState } from "@vencord/discord-types"; import { findByCodeLazy } from "@webpack"; -import { ApplicationStreamingSettingsStore, ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, Toasts, UserStore, VoiceActions, WindowStore } from "@webpack/common"; +import { ApplicationStreamingSettingsStore, ChannelStore, MediaEngineStore, PermissionsBits, PermissionStore, SelectedChannelStore, showToast, UserStore, VoiceActions, WindowStore } from "@webpack/common"; import { getCurrentMedia, settings } from "./utils"; @@ -141,7 +141,7 @@ export default definePlugin({ toolboxActions: { "Instant Screenshare"() { settings.store.toolboxManagement = !settings.store.toolboxManagement; - showToast(`Instant Screenshare ${settings.store.toolboxManagement ? "Enabled" : "Disabled"}`, Toasts.Type.SUCCESS); + showToast(`Instant Screenshare ${settings.store.toolboxManagement ? "Enabled" : "Disabled"}`, "success"); } } }); diff --git a/src/equicordplugins/jumpTo/index.tsx b/src/equicordplugins/jumpTo/index.tsx index 791b2a93b..678591c49 100644 --- a/src/equicordplugins/jumpTo/index.tsx +++ b/src/equicordplugins/jumpTo/index.tsx @@ -8,7 +8,7 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Channel, Message, User } from "@vencord/discord-types"; -import { ChannelStore, Constants, Menu, NavigationRouter, RestAPI, SelectedChannelStore, SelectedGuildStore, Toasts } from "@webpack/common"; +import { ChannelStore, Constants, Menu, NavigationRouter, RestAPI, SelectedChannelStore, SelectedGuildStore, showToast } from "@webpack/common"; function jumpToFirstMessage(channelId: string, guildId?: string | null) { NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}/0`); @@ -38,21 +38,13 @@ async function jumpToUserMessage(channelId: string, guildId: string, userId: str const messageId = res.body?.messages?.[0]?.[0]?.id; if (!messageId) { - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "No messages found from this user in this channel.", - id: Toasts.genId() - }); + showToast("No messages found from this user in this channel.", "failure"); return; } NavigationRouter.transitionTo(`/channels/${guildId}/${channelId}/${messageId}`); } catch (e) { - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "Failed to search for messages.", - id: Toasts.genId() - }); + showToast("Failed to search for messages.", "failure"); } } diff --git a/src/equicordplugins/keyboardNavigation/commands.tsx b/src/equicordplugins/keyboardNavigation/commands.tsx index eb14bdc68..941910d5e 100644 --- a/src/equicordplugins/keyboardNavigation/commands.tsx +++ b/src/equicordplugins/keyboardNavigation/commands.tsx @@ -10,7 +10,8 @@ import { gitHashShort } from "@shared/vencordUserAgent"; import { copyToClipboard } from "@utils/clipboard"; import { relaunch, showItemInFolder } from "@utils/native"; import { checkForUpdates, getRepo } from "@utils/updater"; -import { GuildStore, NavigationRouter, SettingsRouter, Toasts } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { GuildStore, NavigationRouter, SettingsRouter, showToast } from "@webpack/common"; import gitRemote from "~git-remote"; import Plugins from "~plugins"; @@ -46,14 +47,9 @@ export const actions: ButtonAction[] = [ new URL(newUrl); // Throws if invalid VencordNative.native.openExternal(newUrl); } catch { - Toasts.show({ - message: "Invalid URL", - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast("Invalid URL", "failure", { + position: ToastPosition.BOTTOM + }); } }, registrar: "Equicord" }, @@ -92,24 +88,14 @@ export const actions: ButtonAction[] = [ const text = await res.text(); copyToClipboard(text); - Toasts.show({ - message: "Copied response to clipboard!", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast("Copied response to clipboard!", "success", { + position: ToastPosition.BOTTOM + }); } catch (e) { - Toasts.show({ - message: "Issue fetching URL", - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast("Issue fetching URL", "failure", { + position: ToastPosition.BOTTOM + }); } }, registrar: "Equicord" }, @@ -118,14 +104,9 @@ export const actions: ButtonAction[] = [ id: "copyGitInfo", label: "Copy Git Info", callback: async () => { copyToClipboard(`gitHash: ${gitHashShort}\ngitRemote: ${gitRemote}`); - Toasts.show({ - message: "Copied git info to clipboard!", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast("Copied git info to clipboard!", "success", { + position: ToastPosition.BOTTOM + }); }, registrar: "Equicord" }, @@ -144,14 +125,9 @@ export const actions: ButtonAction[] = [ } }), 10_000); } else { - Toasts.show({ - message: "No updates available", - type: Toasts.Type.MESSAGE, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast("No updates available", "message", { + position: ToastPosition.BOTTOM + }); } }, registrar: "Equicord" }, @@ -181,14 +157,9 @@ function togglePlugin(plugin: ButtonAction, enabled: boolean) { Settings.plugins[plugin.id].enabled = enabled; - Toasts.show({ - message: `Successfully ${enabled ? "enabled" : "disabled"} ${plugin.id}`, - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast(`Successfully ${enabled ? "enabled" : "disabled"} ${plugin.id}`, "success", { + position: ToastPosition.BOTTOM + }); } export function registerAction(action: ButtonAction) { diff --git a/src/equicordplugins/lastActive/index.tsx b/src/equicordplugins/lastActive/index.tsx index 44d5ceb42..ac980827a 100644 --- a/src/equicordplugins/lastActive/index.tsx +++ b/src/equicordplugins/lastActive/index.tsx @@ -8,7 +8,7 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { EquicordDevs } from "@utils/constants"; import definePlugin from "@utils/types"; import { Channel } from "@vencord/discord-types"; -import { Menu, NavigationRouter, RestAPI, Toasts, UserStore } from "@webpack/common"; +import { Menu, NavigationRouter, RestAPI, showToast,UserStore } from "@webpack/common"; async function findLastMessageFromUser(guildId: string, channelId: string, userId: string) { try { @@ -33,29 +33,17 @@ async function findLastMessageFromUser(guildId: string, channelId: string, userI if (messageId) return messageId; } catch (error) { console.error("Error finding last message:", error); - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "Failed to find messages. Check console for details.", - id: Toasts.genId() - }); + showToast("Failed to find messages. Check console for details.", "failure"); return null; } - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "Couldn't find any recent messages from this user.", - id: Toasts.genId() - }); + showToast("Couldn't find any recent messages from this user.", "failure"); return null; } async function jumpToLastActive(channel: Channel, targetUserId?: string) { if (!channel) { - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "Channel information not available.", - id: Toasts.genId() - }); + showToast("Channel information not available.", "failure"); return; } @@ -69,11 +57,7 @@ async function jumpToLastActive(channel: Channel, targetUserId?: string) { } } catch (error) { console.error("Error in jumpToLastActive:", error); - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "Failed to jump to message. Check console for details.", - id: Toasts.genId() - }); + showToast("Failed to jump to message. Check console for details.", "failure"); } } diff --git a/src/equicordplugins/messageLoggerEnhanced/components/ClearLogsButton.tsx b/src/equicordplugins/messageLoggerEnhanced/components/ClearLogsButton.tsx index d130d0d6f..0a84b3fb6 100644 --- a/src/equicordplugins/messageLoggerEnhanced/components/ClearLogsButton.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/components/ClearLogsButton.tsx @@ -5,7 +5,7 @@ */ import { Button } from "@components/Button"; -import { Alerts, Toasts, useState } from "@webpack/common"; +import { Alerts, showToast,useState } from "@webpack/common"; import { clearMessagesIDB } from "../db"; import { Flogger } from "../index"; @@ -33,18 +33,10 @@ export function ClearLogsButton({ label = "Clear Logs", onCleared }: ClearLogsBu try { await clearMessagesIDB(); onCleared?.(); - Toasts.show({ - id: Toasts.genId(), - message: "Cleared Logs", - type: Toasts.Type.SUCCESS - }); + showToast("Cleared Logs", "success"); } catch (err) { Flogger.error("Failed to clear logs", err); - Toasts.show({ - id: Toasts.genId(), - message: "Failed to clear logs", - type: Toasts.Type.FAILURE - }); + showToast("Failed to clear logs", "failure"); } finally { setLoading(false); } diff --git a/src/equicordplugins/messageLoggerEnhanced/components/FolderSelectInput.tsx b/src/equicordplugins/messageLoggerEnhanced/components/FolderSelectInput.tsx index 70b9149fa..aa80bf118 100644 --- a/src/equicordplugins/messageLoggerEnhanced/components/FolderSelectInput.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/components/FolderSelectInput.tsx @@ -23,7 +23,7 @@ import { DEFAULT_IMAGE_CACHE_DIR } from "@equicordplugins/messageLoggerEnhanced/ import { copyWithToast } from "@utils/discord"; import { classes } from "@utils/misc"; import { findCssClassesLazy } from "@webpack"; -import { Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; const inputClasses = findCssClassesLazy("input", "inputWrapper", "editable") as Record; @@ -65,17 +65,9 @@ export function SelectFolderInput({ settingsKey, successMessage }: Props) { const res = await Native.chooseDir(settingsKey); settings.store[settingsKey] = res; - return Toasts.show({ - id: Toasts.genId(), - type: Toasts.Type.SUCCESS, - message: successMessage - }); + return showToast(successMessage, "success"); } catch (err) { - Toasts.show({ - id: Toasts.genId(), - type: Toasts.Type.FAILURE, - message: "Failed to update directory" - }); + showToast("Failed to update directory", "failure"); } } diff --git a/src/equicordplugins/messageLoggerEnhanced/db.ts b/src/equicordplugins/messageLoggerEnhanced/db.ts index 12aeac511..4b151a698 100644 --- a/src/equicordplugins/messageLoggerEnhanced/db.ts +++ b/src/equicordplugins/messageLoggerEnhanced/db.ts @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { ChannelStore, Toasts } from "@webpack/common"; +import { ChannelStore, showToast } from "@webpack/common"; import { DBSchema, IDBPDatabase, openDB } from "idb"; import { LoggedMessageJSON } from "./types"; @@ -256,7 +256,7 @@ export async function deleteMessagesBulkIDB(message_ids: string[]) { message_ids.forEach(id => cachedMessages.delete(id)); } -export async function clearMessagesIDB(showToast = true) { +export async function clearMessagesIDB(toast = true) { cachedMessages.clear(); const deleted = await new Promise(resolve => { @@ -271,13 +271,9 @@ export async function clearMessagesIDB(showToast = true) { cachedMessages.clear(); - if (!showToast) return; + if (!toast) return; - Toasts.show({ - type: Toasts.Type.MESSAGE, - message: "Cleared message log database and cache.", - id: Toasts.genId() - }); + showToast("Cleared message log database and cache.", "message"); } // faster than db.clear on large dbs diff --git a/src/equicordplugins/messageLoggerEnhanced/index.tsx b/src/equicordplugins/messageLoggerEnhanced/index.tsx index 74ed23179..f9129067e 100644 --- a/src/equicordplugins/messageLoggerEnhanced/index.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/index.tsx @@ -41,8 +41,8 @@ let didClearLogsOnStartup = false; const cacheThing = findByPropsLazy("commit", "getOrCreate"); -export async function clearLogs(showToast = true) { - await idb.clearMessagesIDB(showToast); +export async function clearLogs(toast = true) { + await idb.clearMessagesIDB(toast); cacheSentMessages.clear(); } diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx b/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx index 97a9f65e2..c91096301 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/utils/contextMenu.tsx @@ -6,7 +6,7 @@ import { addContextMenuPatch, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu"; import { updateMessage } from "@api/MessageUpdater"; -import { FluxDispatcher, Menu, MessageActions, React, SortedGuildStore, Toasts, UserStore } from "@webpack/common"; +import { FluxDispatcher, Menu, MessageActions, React, showToast,SortedGuildStore, UserStore } from "@webpack/common"; import { openLogModal } from "../components/LogsModal"; import { deleteMessageIDB } from "../db"; @@ -80,11 +80,7 @@ const removeMessageAction = async (props: any) => { } } catch (e) { console.error("Failed to remove message", e); - Toasts.show({ - type: Toasts.Type.FAILURE, - message: "Failed to remove message. Check console for details.", - id: Toasts.genId() - }); + showToast("Failed to remove message. Check console for details.", "failure"); } }; diff --git a/src/equicordplugins/messageLoggerEnhanced/utils/settingsUtils.ts b/src/equicordplugins/messageLoggerEnhanced/utils/settingsUtils.ts index 0d59e56ab..728379f39 100644 --- a/src/equicordplugins/messageLoggerEnhanced/utils/settingsUtils.ts +++ b/src/equicordplugins/messageLoggerEnhanced/utils/settingsUtils.ts @@ -18,7 +18,7 @@ import JSONParser from "@streamparser/json/jsonparser.js"; import { chooseFile as chooseFileWeb } from "@utils/web"; -import { Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; import { showSaveFilePicker } from "native-file-system-adapter"; import { clearLogs,Native } from ".."; @@ -60,27 +60,15 @@ export async function importLogs() { } if (count === 0) { - Toasts.show({ - id: Toasts.genId(), - message: "No messages found in log file", - type: Toasts.Type.FAILURE - }); + showToast("No messages found in log file", "failure"); return; } - Toasts.show({ - id: Toasts.genId(), - message: `Successfully imported ${count} logs`, - type: Toasts.Type.SUCCESS - }); + showToast(`Successfully imported ${count} logs`, "success"); } catch (e) { console.error(e); - Toasts.show({ - id: Toasts.genId(), - message: "Error importing logs. Check the console for more information", - type: Toasts.Type.FAILURE - }); + showToast("Error importing logs. Check the console for more information", "failure"); } } @@ -106,11 +94,7 @@ export async function exportLogs() { await Native.writeNativeLogChunk(streamId, "\n ]\n}"); await Native.finishNativeLogExport(streamId); - Toasts.show({ - id: Toasts.genId(), - message: "Successfully exported logs", - type: Toasts.Type.SUCCESS - }); + showToast("Successfully exported logs", "success"); return; } @@ -143,20 +127,12 @@ export async function exportLogs() { await writer.write(encoder.encode("\n ]\n}")); await writer.close(); - Toasts.show({ - id: Toasts.genId(), - message: `Successfully exported ${count} logs`, - type: Toasts.Type.SUCCESS - }); + showToast(`Successfully exported ${count} logs`, "success"); } } catch (e) { console.error(e); - Toasts.show({ - id: Toasts.genId(), - message: "Error exporting logs. Check the console for more information", - type: Toasts.Type.FAILURE - }); + showToast("Error exporting logs. Check the console for more information", "failure"); } } diff --git a/src/equicordplugins/moreStickers/components/misc.tsx b/src/equicordplugins/moreStickers/components/misc.tsx index 4c3ac9325..7077b0e03 100644 --- a/src/equicordplugins/moreStickers/components/misc.tsx +++ b/src/equicordplugins/moreStickers/components/misc.tsx @@ -17,7 +17,7 @@ import { isV1, migrate } from "@equicordplugins/moreStickers/migrate-v1"; import { deleteStickerPack, getStickerPack, getStickerPackMetas, saveStickerPack } from "@equicordplugins/moreStickers/stickers"; import { SettingsTabsKey, Sticker, StickerPack, StickerPackMeta } from "@equicordplugins/moreStickers/types"; import { cl, clPicker, Mutex } from "@equicordplugins/moreStickers/utils"; -import { Button, React, TabBar, TextArea, Toasts } from "@webpack/common"; +import { Button, React, showToast,TabBar, TextArea } from "@webpack/common"; import { JSX } from "react"; const mutex = new Mutex(); @@ -58,24 +58,14 @@ const StickerPackMetadata = ({ meta, hoveredStickerPackId, setHoveredStickerPack onClick={async () => { try { await deleteStickerPack(meta.id); - Toasts.show({ - message: "Sticker Pack deleted", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { + showToast("Sticker Pack deleted", "success", { duration: 1000 - } - }); + }); await refreshStickerPackMetas(); } catch (e: any) { - Toasts.show({ - message: e.message, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { + showToast(e.message, "failure", { duration: 1000 - } - }); + }); } }} > @@ -210,23 +200,13 @@ export const Packs = () => { refreshStickerPackMetas(); if (errorMessage) { - Toasts.show({ - message: errorMessage, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { + showToast(errorMessage, "failure", { duration: 1000 - } - }); + }); } else { - Toasts.show({ - message: "Sticker Pack added", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { + showToast("Sticker Pack added", "success", { duration: 1000 - } - }); + }); } }} @@ -288,23 +268,13 @@ export const Packs = () => { refreshStickerPackMetas(); if (errorMessage) { - Toasts.show({ - message: errorMessage, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { + showToast(errorMessage, "failure", { duration: 1000 - } - }); + }); } else { - Toasts.show({ - message: "Sticker Pack added", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { + showToast("Sticker Pack added", "success", { duration: 1000 - } - }); + }); } }} >Insert from HTML @@ -340,24 +310,14 @@ export const Packs = () => { await saveStickerPack(stickerPack); } - Toasts.show({ - message: "Sticker Packs added", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { + showToast("Sticker Packs added", "success", { duration: 1000 - } - }); + }); } catch (e: any) { console.error(e); - Toasts.show({ - message: e.message, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { + showToast(e.message, "failure", { duration: 1000 - } - }); + }); } }; input.click(); @@ -395,14 +355,9 @@ export const Packs = () => { a.click(); setTimeout(() => URL.revokeObjectURL(objectUrl), 1000); - Toasts.show({ - message: "Sticker Packs exported", - type: Toasts.Type.SUCCESS, - id: Toasts.genId(), - options: { + showToast("Sticker Packs exported", "success", { duration: 1000 - } - }); + }); }} >Export Sticker Packs @@ -84,7 +85,6 @@ const settings = definePluginSettings({ } }); -let activeToastId: string | null = null; let overlayModalKey: string | null = null; let overlayRerender: (() => void) | null = null; @@ -164,7 +164,6 @@ function endCycleSession() { cycleSnapshot = []; cycleIndex = -1; - activeToastId = null; const visEnd = (settings as any).store?.visualStyle; if (visEnd === "overlay") unmountOverlay(); @@ -319,13 +318,7 @@ function showCycleToast() { const id = cycleSnapshot[cycleIndex]; if (!id) return; const { name } = getDisplayForChannel(id); - if (!activeToastId) activeToastId = Toasts.genId(); - Toasts.show({ - id: activeToastId, - message: `Switching to: ${name}`, - type: Toasts.Type.MESSAGE, - options: { position: Toasts.Position.BOTTOM, duration: settings.store.toastDurationMs } - }); + showToast(`Switching to: ${name}`, "message", { position: ToastPosition.BOTTOM, duration: settings.store.toastDurationMs }); } export default definePlugin({ @@ -369,7 +362,6 @@ export default definePlugin({ suppressRdmsWhileCycling = false; cycleSnapshot = []; cycleIndex = -1; - activeToastId = null; const visEnd = (settings as any).store?.visualStyle; if (visEnd === "overlay") unmountOverlay(); diff --git a/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx b/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx index d9126e8bf..8a9d5b0f2 100644 --- a/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx +++ b/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx @@ -10,7 +10,7 @@ import { Heading } from "@components/Heading"; import { classNameFactory } from "@utils/css"; import { RenderModalProps } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; -import { ChannelStore, closeModal, DraftType, Modal, openModal, showToast, TextInput, Toasts, UploadManager, useState } from "@webpack/common"; +import { ChannelStore, closeModal, DraftType, Modal, openModal, showToast, TextInput, UploadManager, useState } from "@webpack/common"; import { ScheduledAttachment } from "../types"; import { addScheduledMessage, getChannelDisplayInfo } from "../utils"; @@ -61,7 +61,7 @@ function ScheduleTimeModalInner({ channelId, content, attachments, rootProps, cl if (result.success) { ComponentDispatch.dispatchToLastSubscribed("CLEAR_TEXT"); UploadManager.clearAll(channelId, DraftType.ChannelMessage); - showToast("Message scheduled!", Toasts.Type.SUCCESS); + showToast("Message scheduled!", "success"); close(); } else { setError(result.error ?? "Failed to schedule message"); diff --git a/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx b/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx index 0fb99f605..f6154db2c 100644 --- a/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx +++ b/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx @@ -8,7 +8,7 @@ import { Button } from "@components/Button"; import ErrorBoundary from "@components/ErrorBoundary"; import { classNameFactory } from "@utils/css"; import { RenderModalProps } from "@vencord/discord-types"; -import { ChannelStore, closeModal, Modal, openModal, showToast, Toasts, useState } from "@webpack/common"; +import { ChannelStore, closeModal, Modal, openModal, showToast, useState } from "@webpack/common"; import { clearAllScheduledMessages, getChannelDisplayInfo, getScheduledMessages, removeScheduledMessage } from "../utils"; import { CalendarIcon, TimerIcon } from "./Icons"; @@ -26,13 +26,13 @@ function ViewScheduledModalInner({ rootProps, close }: ViewScheduledModalProps) const handleDelete = async (id: string) => { await removeScheduledMessage(id); setMessages(getScheduledMessages()); - showToast("Scheduled message removed", Toasts.Type.SUCCESS); + showToast("Scheduled message removed", "success"); }; const handleClearAll = async () => { await clearAllScheduledMessages(); setMessages([]); - showToast("All scheduled messages cleared", Toasts.Type.SUCCESS); + showToast("All scheduled messages cleared", "success"); }; const actions = [ diff --git a/src/equicordplugins/scheduledMessages/utils.ts b/src/equicordplugins/scheduledMessages/utils.ts index a99b7e0ca..0e7884c28 100644 --- a/src/equicordplugins/scheduledMessages/utils.ts +++ b/src/equicordplugins/scheduledMessages/utils.ts @@ -8,7 +8,7 @@ import * as DataStore from "@api/DataStore"; import { Logger } from "@utils/Logger"; import { Message } from "@vencord/discord-types"; import { CloudUploadPlatform } from "@vencord/discord-types/enums"; -import { ChannelStore, CloudUploader, Constants, FluxDispatcher, GuildStore, IconUtils, MessageActions, MessageStore, RestAPI, showToast, SnowflakeUtils, Toasts, UserStore } from "@webpack/common"; +import { ChannelStore, CloudUploader, Constants, FluxDispatcher, GuildStore, IconUtils, MessageActions, MessageStore, RestAPI, showToast, SnowflakeUtils, UserStore } from "@webpack/common"; import { settings } from "."; import { PhantomMessageData, ScheduledAttachment, ScheduledMessage, ScheduledReaction } from "./types"; @@ -374,11 +374,11 @@ async function sendScheduledMessage(msg: ScheduledMessage): Promise { } if (settings.store.showNotifications) { - showToast(`Scheduled message sent to ${getChannelDisplayInfo(msg.channelId).name}`, Toasts.Type.SUCCESS); + showToast(`Scheduled message sent to ${getChannelDisplayInfo(msg.channelId).name}`, "success"); } return true; } catch { - if (settings.store.showNotifications) showToast("Failed to send scheduled message", Toasts.Type.FAILURE); + if (settings.store.showNotifications) showToast("Failed to send scheduled message", "failure"); return false; } } diff --git a/src/equicordplugins/showMessageEmbeds/index.tsx b/src/equicordplugins/showMessageEmbeds/index.tsx index 84aabc02d..8d27c6120 100644 --- a/src/equicordplugins/showMessageEmbeds/index.tsx +++ b/src/equicordplugins/showMessageEmbeds/index.tsx @@ -12,8 +12,9 @@ import { Logger } from "@utils/Logger"; import { parseUrl } from "@utils/misc"; import definePlugin from "@utils/types"; import { Message } from "@vencord/discord-types"; +import { ToastPosition } from "@vencord/discord-types/enums"; import { findByCodeLazy } from "@webpack"; -import { ChannelStore, Constants, Menu, MessageStore, React, RestAPI, showToast, Toasts } from "@webpack/common"; +import { ChannelStore, Constants, Menu, MessageStore, React, RestAPI, showToast } from "@webpack/common"; const logger = new Logger("ShowMessageEmbeds"); @@ -189,7 +190,7 @@ function removeEmbed(url: string, message: Message) { } function showFailureToast(message: string) { - showToast(message, Toasts.Type.FAILURE, { position: Toasts.Position.BOTTOM }); + showToast(message, "failure", { position: ToastPosition.BOTTOM }); } export default definePlugin({ diff --git a/src/equicordplugins/songSpotlight.desktop/lib/api.ts b/src/equicordplugins/songSpotlight.desktop/lib/api.ts index c751830f1..eca025436 100644 --- a/src/equicordplugins/songSpotlight.desktop/lib/api.ts +++ b/src/equicordplugins/songSpotlight.desktop/lib/api.ts @@ -5,7 +5,7 @@ */ import type { UserData } from "@song-spotlight/api/structs"; -import { showToast, Toasts, UserStore } from "@webpack/common"; +import { showToast, UserStore } from "@webpack/common"; import { useAuthorizationStore } from "./stores/AuthorizationStore"; import { useSongStore } from "./stores/SongStore"; @@ -65,20 +65,20 @@ export async function authFetch(url: string | URL, options?: RequestInit, retrie if (retry) return await authFetch(url, options, true); else { useAuthorizationStore.getState().deleteTokens(); - showToast("You have been signed out from Song Spotlight. Please sign in again.", Toasts.Type.FAILURE); + showToast("You have been signed out from Song Spotlight. Please sign in again.", "failure"); } } else { showToast( !text.includes("") && res.status >= 400 && res.status <= 599 ? `Song Spotlight: ${text}` : `Song Spotlight fetch error at ${url.pathname}`, - Toasts.Type.FAILURE, + "failure", ); } throw new Error(text); } catch (error) { - showToast(`Song Spotlight: ${error}`, Toasts.Type.FAILURE); + showToast(`Song Spotlight: ${error}`, "failure"); throw error; } diff --git a/src/equicordplugins/songSpotlight.desktop/lib/oauth2.tsx b/src/equicordplugins/songSpotlight.desktop/lib/oauth2.tsx index 2cee55f1f..bb970510b 100644 --- a/src/equicordplugins/songSpotlight.desktop/lib/oauth2.tsx +++ b/src/equicordplugins/songSpotlight.desktop/lib/oauth2.tsx @@ -5,7 +5,7 @@ */ import { ApplicationIntegrationType } from "@vencord/discord-types/enums"; -import { OAuth2AuthorizeModal, openModal,showToast, Toasts } from "@webpack/common"; +import { OAuth2AuthorizeModal, openModal, showToast } from "@webpack/common"; import { apiConstants, authFetch, getData } from "./api"; import { useAuthorizationStore } from "./stores/AuthorizationStore"; @@ -41,10 +41,10 @@ export function presentOAuth2Modal() { useAuthorizationStore.getState().setToken(access, refresh); getData(); - showToast("Successfully authorized!", Toasts.Type.SUCCESS); + showToast("Successfully authorized!", "success"); } catch (error) { logger.error("Got an error during OAuth2", error); - if (typeof error === "string") showToast(error, Toasts.Type.FAILURE); + if (typeof error === "string") showToast(error, "failure"); } }} /> diff --git a/src/equicordplugins/songSpotlight.desktop/ui/components/AudioPlayer.tsx b/src/equicordplugins/songSpotlight.desktop/ui/components/AudioPlayer.tsx index 904625837..59dd6ba3e 100644 --- a/src/equicordplugins/songSpotlight.desktop/ui/components/AudioPlayer.tsx +++ b/src/equicordplugins/songSpotlight.desktop/ui/components/AudioPlayer.tsx @@ -7,7 +7,7 @@ import { logger } from "@equicordplugins/songSpotlight.desktop/lib/utils"; import settings from "@equicordplugins/songSpotlight.desktop/settings"; import { RenderInfoEntry, RenderInfoEntryAudio } from "@song-spotlight/api/handlers"; -import { showToast, Toasts, useCallback, useEffect, useMemo, useRef } from "@webpack/common"; +import { showToast, useCallback, useEffect, useMemo, useRef } from "@webpack/common"; import { RefObject } from "react"; interface AudioItemProps { @@ -103,7 +103,7 @@ export default function AudioPlayer({ audioRef, list, playing, setPlaying, setLo node.currentTime = audio.previewStart ? audio.previewStart / 1000 : 0; node.volume = BASE_VOLUME * (settings.store.previewVolume / 100); node.play().catch(error => { - showToast("Failed to play song preview!", Toasts.Type.FAILURE); + showToast("Failed to play song preview!", "failure"); logger.error("Failed to play audio", error); setPlaying(undefined); }); diff --git a/src/equicordplugins/songSpotlight.desktop/ui/settings/index.tsx b/src/equicordplugins/songSpotlight.desktop/ui/settings/index.tsx index 9f88f7f9c..09ad7acce 100644 --- a/src/equicordplugins/songSpotlight.desktop/ui/settings/index.tsx +++ b/src/equicordplugins/songSpotlight.desktop/ui/settings/index.tsx @@ -21,7 +21,7 @@ import { sid } from "@song-spotlight/api/util"; import { readClipboard } from "@utils/clipboard"; import { copyWithToast } from "@utils/discord"; import { RenderModalProps } from "@vencord/discord-types"; -import { Alerts, Modal,openModal, Parser, showToast, Toasts, useCallback, useEffect, useMemo, useRef, useState } from "@webpack/common"; +import { Alerts, Modal, openModal, Parser, showToast, useCallback, useEffect, useMemo, useRef, useState } from "@webpack/common"; interface ImportButtonProps { overwrite: boolean; @@ -39,24 +39,24 @@ function ImportButton({ overwrite, pending, setPending, onImport }: ImportButton json = JSON.parse(await readClipboard()); } catch { setPending(false); - return showToast("No JSON in clipboard!", Toasts.Type.FAILURE); + return showToast("No JSON in clipboard!", "failure"); } const { error, data } = UserDataSchema.max(apiConstants.songLimit).safeParse(json); if (error) { setPending(false); - return showToast("Invalid Song Spotlight data in clipboard!", Toasts.Type.FAILURE); + return showToast("Invalid Song Spotlight data in clipboard!", "failure"); } const validated = await Promise.allSettled(data.map(song => Native.validateSong(song))); if (!validated.every(x => x.status === "fulfilled" && x.value)) { setPending(false); - return showToast("One or more imported songs were invalid.", Toasts.Type.FAILURE); + return showToast("One or more imported songs were invalid.", "failure"); } onImport(data); setPending(false); - showToast("Imported songs from clipboard!", Toasts.Type.SUCCESS); + showToast("Imported songs from clipboard!", "success"); }, [pending]); return ( @@ -153,7 +153,7 @@ export default function Settings({ templateData }: SettingsProps) { setPending(true); try { await saveData(localData); - showToast("Successfully saved songs!", Toasts.Type.SUCCESS); + showToast("Successfully saved songs!", "success"); } finally { setPending(false); } @@ -173,7 +173,7 @@ export default function Settings({ templateData }: SettingsProps) { variant="dangerPrimary" onClick={() => { deleteTokens(); - showToast("Successfully signed out!", Toasts.Type.SUCCESS); + showToast("Successfully signed out!", "success"); }} disabled={pending} > @@ -191,7 +191,7 @@ export default function Settings({ templateData }: SettingsProps) { await deleteData(); deleteTokens(); - showToast("Successfully deleted songs!", Toasts.Type.SUCCESS); + showToast("Successfully deleted songs!", "success"); } finally { setPending(false); } diff --git a/src/equicordplugins/songSpotlight.desktop/ui/songs/CollapsedProfileSongs.tsx b/src/equicordplugins/songSpotlight.desktop/ui/songs/CollapsedProfileSongs.tsx index 5c0d4386c..95348ee79 100644 --- a/src/equicordplugins/songSpotlight.desktop/ui/songs/CollapsedProfileSongs.tsx +++ b/src/equicordplugins/songSpotlight.desktop/ui/songs/CollapsedProfileSongs.tsx @@ -19,11 +19,11 @@ import { sid } from "@song-spotlight/api/util"; import { classes } from "@utils/misc"; import { User } from "@vencord/discord-types"; import { + openUserProfileModal, SelectedChannelStore, SelectedGuildStore, useEffect, useMemo, - UserProfileActions, UserStore, useState, } from "@webpack/common"; @@ -70,10 +70,14 @@ export default function CollapsedProfileSongs({ data, user, isSideBar, isRedesig if (!user) return; const guildId = SelectedGuildStore.getGuildId(); - UserProfileActions.openUserProfileModal({ + openUserProfileModal({ userId, guildId, channelId: SelectedChannelStore.getChannelId(), + sourceAnalyticsLocations: [ + "username", + "user profile popout", + ], tabSection: "SONG_SPOTLIGHT", }); }} diff --git a/src/equicordplugins/songSpotlight.desktop/ui/songs/index.tsx b/src/equicordplugins/songSpotlight.desktop/ui/songs/index.tsx index 9fd736699..bfa7daf13 100644 --- a/src/equicordplugins/songSpotlight.desktop/ui/songs/index.tsx +++ b/src/equicordplugins/songSpotlight.desktop/ui/songs/index.tsx @@ -30,21 +30,7 @@ import { Song as SongType } from "@song-spotlight/api/structs"; import { isListLayout, sid } from "@song-spotlight/api/util"; import { copyWithToast } from "@utils/discord"; import { classes } from "@utils/misc"; -import { - Clickable, - ContextMenuApi, - FluxDispatcher, - Menu, - React, - ScrollerThin, - showToast, - Toasts, - Tooltip, - useCallback, - useMemo, - useRef, - useState -} from "@webpack/common"; +import { Clickable, ContextMenuApi, FluxDispatcher, Menu, React, ScrollerThin, showToast, Tooltip, useCallback, useMemo, useRef, useState } from "@webpack/common"; interface SongEntryProps { entry: RenderInfoEntryBased; @@ -88,7 +74,7 @@ function SongEntry({ entry, number, isLoaded, isPlaying, big, onClick }: SongEnt const song = await Native.parseLink(entry.link); if (!song) { - return showToast("Uh oh, this song doesn't exist!", Toasts.Type.FAILURE); + return showToast("Uh oh, this song doesn't exist!", "failure"); } if (self.find(x => sid(x) === sid(song))) { diff --git a/src/equicordplugins/splitLargeMessages/index.ts b/src/equicordplugins/splitLargeMessages/index.ts index f8735b10f..c57095b3e 100644 --- a/src/equicordplugins/splitLargeMessages/index.ts +++ b/src/equicordplugins/splitLargeMessages/index.ts @@ -12,7 +12,7 @@ import { Logger } from "@utils/Logger"; import { sleep } from "@utils/misc"; import definePlugin, { makeRange, OptionType } from "@utils/types"; import type { Channel } from "@vencord/discord-types"; -import { ChannelStore, ComponentDispatch, PermissionsBits, PermissionStore, Toasts, UserStore } from "@webpack/common"; +import { ChannelStore, ComponentDispatch, PermissionsBits, PermissionStore, showToast,UserStore } from "@webpack/common"; import { splitMessage, type SplitMode } from "./splitMessage"; @@ -120,11 +120,7 @@ const listener: MessageSendListener = async (channelId, message) => { const channel = ChannelStore.getChannel(channelId); if (!canSplitInChannel(channel)) { - Toasts.show({ - message: "Cannot split this message because of the channel's slowmode.", - id: "vc-splitLargeMessages-blocked", - type: Toasts.Type.FAILURE, - }); + showToast("Cannot split this message because of the channel's slowmode.", "failure"); return { cancel: true }; } @@ -134,11 +130,7 @@ const listener: MessageSendListener = async (channelId, message) => { const sent = await sendChunks(channelId, chunks, getSendDelay(channel)); if (sent !== chunks.length) { restoreUnsentContent(channelId, chunks, sent); - Toasts.show({ - message: `Only ${sent}/${chunks.length} message parts were sent.`, - id: "vc-splitLargeMessages-failure", - type: Toasts.Type.FAILURE, - }); + showToast(`Only ${sent}/${chunks.length} message parts were sent.`, "failure"); } return { cancel: true }; diff --git a/src/equicordplugins/statusPresets/index.tsx b/src/equicordplugins/statusPresets/index.tsx index ea0073d33..375602bd0 100644 --- a/src/equicordplugins/statusPresets/index.tsx +++ b/src/equicordplugins/statusPresets/index.tsx @@ -26,7 +26,7 @@ import { proxyLazy } from "@utils/lazy"; import { useForceUpdater } from "@utils/react"; import definePlugin, { OptionType, StartAt } from "@utils/types"; import { extractAndLoadChunksLazy, findComponentByCodeLazy, findModuleId, wreq } from "@webpack"; -import { Menu, openModalLazy, OverridePremiumTypeStore, Toasts } from "@webpack/common"; +import { Menu, openModalLazy, OverridePremiumTypeStore, showToast } from "@webpack/common"; interface Emoji { animated: boolean; @@ -189,11 +189,7 @@ export default definePlugin({ style: { marginLeft: "20px" }, onClick: () => { settings.store.StatusPresets[status.text] = status; - Toasts.show({ - message: "Successfully Saved Status", - type: Toasts.Type.SUCCESS, - id: Toasts.genId() - }); + showToast("Successfully Saved Status", "success"); } }; }, diff --git a/src/equicordplugins/streaks/stores/AuthorizationStore.tsx b/src/equicordplugins/streaks/stores/AuthorizationStore.tsx index 580cc0672..2d1d2860c 100644 --- a/src/equicordplugins/streaks/stores/AuthorizationStore.tsx +++ b/src/equicordplugins/streaks/stores/AuthorizationStore.tsx @@ -7,7 +7,7 @@ import * as DataStore from "@api/DataStore"; import { proxyLazy } from "@utils/lazy"; import { Logger } from "@utils/Logger"; -import { OAuth2AuthorizeModal, openModal, showToast, Toasts, UserStore, zustandCreate, zustandPersist } from "@webpack/common"; +import { OAuth2AuthorizeModal, openModal, showToast, UserStore, zustandCreate, zustandPersist } from "@webpack/common"; import { AUTHORIZE_URL, CLIENT_ID } from "../constants"; import { useStreaksStore } from "./StreaksStore"; @@ -78,7 +78,7 @@ export const useAuthorizationStore = proxyLazy(() => zustandCreate( resolve(void 0); } catch (e) { if (e instanceof Error) { - showToast(`Failed to authorize: ${e.message}`, Toasts.Type.FAILURE); + showToast(`Failed to authorize: ${e.message}`, "failure"); new Logger("Streaks").error("Failed to authorize", e); reject(e); } diff --git a/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx b/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx index 37170d22f..6b411d366 100644 --- a/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx +++ b/src/equicordplugins/themeLibrary/components/ThemeInfoModal.tsx @@ -15,7 +15,7 @@ import { openInviteModal } from "@utils/discord"; import { Margins } from "@utils/margins"; import type { PluginNative } from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; -import { Button, Modal, openModal, Parser, React, showToast, Toasts } from "@webpack/common"; +import { Button, Modal, openModal, Parser, React, showToast } from "@webpack/common"; import { logger } from "./ThemeTab"; @@ -25,10 +25,10 @@ const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaul async function downloadTheme(theme: Theme) { try { await Native.downloadTheme(theme); - showToast(`Downloaded ${theme.name}!`, Toasts.Type.SUCCESS); + showToast(`Downloaded ${theme.name}!`, "success"); } catch (err: unknown) { logger.error(err); - showToast(`Failed to download ${theme.name}! (check console)`, Toasts.Type.FAILURE); + showToast(`Failed to download ${theme.name}! (check console)`, "failure"); } } @@ -166,7 +166,7 @@ export const ThemeInfoModal: React.FC = ({ author, theme, . onClick={async e => { e.preventDefault(); const useInvite = guild ? guild.invite_link?.split("discord.gg/")[1] : invite; - useInvite != null && openInviteModal(useInvite).catch(() => showToast("Invalid or expired invite!", Toasts.Type.FAILURE)); + useInvite != null && openInviteModal(useInvite).catch(() => showToast("Invalid or expired invite!", "failure")); }} > Join Discord Server @@ -194,7 +194,7 @@ export const ThemeInfoModal: React.FC = ({ author, theme, . variant: "primary", onClick: () => { copyToClipboard(themeContent); - showToast("Copied to Clipboard", Toasts.Type.SUCCESS); + showToast("Copied to Clipboard", "success"); } } ]} diff --git a/src/equicordplugins/themeLibrary/utils/auth.tsx b/src/equicordplugins/themeLibrary/utils/auth.tsx index a39d1c358..6cb05350b 100644 --- a/src/equicordplugins/themeLibrary/utils/auth.tsx +++ b/src/equicordplugins/themeLibrary/utils/auth.tsx @@ -7,7 +7,8 @@ import * as DataStore from "@api/DataStore"; import { showNotification } from "@api/Notifications"; import { logger, themeRequest } from "@equicordplugins/themeLibrary/components/ThemeTab"; -import { OAuth2AuthorizeModal, openModal,Toasts, UserStore } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { OAuth2AuthorizeModal, openModal, showToast,UserStore } from "@webpack/common"; export async function authorizeUser(triggerModal: boolean = true) { const isAuthorized = await getAuthorization(); @@ -64,15 +65,10 @@ export async function authorizeUser(triggerModal: boolean = true) { export async function deauthorizeUser() { const uniqueToken = await DataStore.get>("ThemeLibrary_uniqueToken"); - if (!uniqueToken) return Toasts.show({ - message: "No uniqueToken present, try authorizing first!", - id: Toasts.genId(), - type: Toasts.Type.FAILURE, - options: { + if (!uniqueToken) return showToast("No uniqueToken present, try authorizing first!", "failure", { duration: 2e3, - position: Toasts.Position.BOTTOM - } - }); + position: ToastPosition.BOTTOM + }); const res = await themeRequest("/user/revoke", { method: "DELETE", diff --git a/src/equicordplugins/themeLibrary/utils/settings.tsx b/src/equicordplugins/themeLibrary/utils/settings.tsx index f7992a469..c92a1346e 100644 --- a/src/equicordplugins/themeLibrary/utils/settings.tsx +++ b/src/equicordplugins/themeLibrary/utils/settings.tsx @@ -12,7 +12,8 @@ import { Paragraph } from "@components/Paragraph"; import { copyToClipboard } from "@utils/clipboard"; import { classNameFactory } from "@utils/css"; import { OptionType } from "@utils/types"; -import { Button, Toasts } from "@webpack/common"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { Button, showToast } from "@webpack/common"; import { authorizeUser, deauthorizeUser } from "./auth"; @@ -32,27 +33,17 @@ export const settings = definePluginSettings({ const handleClick = async () => { const token = await DataStore.get("ThemeLibrary_uniqueToken"); - if (!token) return Toasts.show({ - message: "No token to copy, try authorizing first!", - id: Toasts.genId(), - type: Toasts.Type.FAILURE, - options: { + if (!token) return showToast("No token to copy, try authorizing first!", "failure", { duration: 2.5e3, - position: Toasts.Position.BOTTOM - } - }); + position: ToastPosition.BOTTOM + }); copyToClipboard(token); - Toasts.show({ - message: "Copied to Clipboard!", - id: Toasts.genId(), - type: Toasts.Type.SUCCESS, - options: { + showToast("Copied to Clipboard!", "success", { duration: 2.5e3, - position: Toasts.Position.BOTTOM - } - }); + position: ToastPosition.BOTTOM + }); }; return ( diff --git a/src/equicordplugins/timezones/database.tsx b/src/equicordplugins/timezones/database.tsx index eb6cb378c..d62f8d88e 100644 --- a/src/equicordplugins/timezones/database.tsx +++ b/src/equicordplugins/timezones/database.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { OAuth2AuthorizeModal, openModal, showToast, Toasts } from "@webpack/common"; +import { OAuth2AuthorizeModal, openModal, showToast } from "@webpack/common"; import { settings } from "."; @@ -22,7 +22,7 @@ function getRedirectUri(): string { function handleApiError(error: any, defaultMessage: string): void { console.error(defaultMessage, error); const message = error?.message || defaultMessage; - showToast(message, Toasts.Type.FAILURE); + showToast(message, "failure"); } async function safeJsonParse(response: Response): Promise { @@ -111,7 +111,7 @@ async function setTimezoneInternal(timezone: string): Promise { return false; } - showToast("Timezone updated successfully!", Toasts.Type.SUCCESS); + showToast("Timezone updated successfully!", "success"); return true; } catch (e) { handleApiError(e, "Failed to set timezone"); @@ -149,7 +149,7 @@ async function deleteTimezoneInternal(): Promise { return false; } - showToast("Timezone deleted successfully!", Toasts.Type.SUCCESS); + showToast("Timezone deleted successfully!", "success"); return true; } catch (e) { handleApiError(e, "Failed to delete timezone"); @@ -180,7 +180,7 @@ export function authModal(callback?: () => void) { handleApiError(json, "Authorization failed"); return; } - showToast("Authorization successful!", Toasts.Type.SUCCESS); + showToast("Authorization successful!", "success"); callback?.(); } catch (e) { handleApiError(e, "Unexpected error during authorization"); diff --git a/src/equicordplugins/timezones/index.tsx b/src/equicordplugins/timezones/index.tsx index 7d0590544..02357a5a6 100644 --- a/src/equicordplugins/timezones/index.tsx +++ b/src/equicordplugins/timezones/index.tsx @@ -13,8 +13,9 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs, EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { Message, User } from "@vencord/discord-types"; +import { ToastPosition } from "@vencord/discord-types/enums"; import { findByPropsLazy, findCssClassesLazy } from "@webpack"; -import { Button, ChannelStore, Menu, openModal, showToast, Toasts, Tooltip, useEffect, UserStore, useState } from "@webpack/common"; +import { Button, ChannelStore, Menu, openModal, showToast, Tooltip, useEffect, UserStore, useState } from "@webpack/common"; import { deleteTimezone, getTimezone, loadDatabaseTimezones, setUserDatabaseTimezone } from "./database"; import { SetTimezoneModal } from "./TimezoneModal"; @@ -127,7 +128,7 @@ export const settings = definePluginSettings({ await deleteTimezone(); } catch (error) { console.error("Error resetting database timezone:", error); - showToast("Failed to reset database timezone", Toasts.Type.FAILURE); + showToast("Failed to reset database timezone", "failure"); } }} > @@ -312,14 +313,14 @@ export default definePlugin({ const good = await loadDatabaseTimezones(); if (good) { - showToast("Timezones refreshed successfully!", Toasts.Type.SUCCESS); + showToast("Timezones refreshed successfully!", "success"); } else { - showToast("Timezones Failed to refresh!", Toasts.Type.FAILURE); + showToast("Timezones Failed to refresh!", "failure"); } } catch (error) { console.error("Failed to refresh timezone:", error); - showToast("Failed to refresh timezones.", Toasts.Type.FAILURE); + showToast("Failed to refresh timezones.", "failure"); } } }, @@ -333,7 +334,7 @@ export default definePlugin({ if (!settings.store.askedTimezone) { showToast( "", - Toasts.Type.MESSAGE, + "message", { duration: 10000, component: ( @@ -346,7 +347,7 @@ export default definePlugin({ Want to save your timezone to the database? Click here to set it. ), - position: Toasts.Position.BOTTOM + position: ToastPosition.BOTTOM } ); settings.store.askedTimezone = true; diff --git a/src/equicordplugins/triviaAI/utils.ts b/src/equicordplugins/triviaAI/utils.ts index cda8b3483..fe2276736 100644 --- a/src/equicordplugins/triviaAI/utils.ts +++ b/src/equicordplugins/triviaAI/utils.ts @@ -8,7 +8,7 @@ import { sendBotMessage } from "@api/Commands"; import { insertTextIntoChatInputBox, sendMessage } from "@utils/discord"; import { Logger } from "@utils/Logger"; import { Message } from "@vencord/discord-types"; -import { MessageStore, showToast, Toasts, UserStore } from "@webpack/common"; +import { MessageStore, showToast, UserStore } from "@webpack/common"; import { settings } from "./settings"; @@ -225,7 +225,7 @@ function getSystemPrompt() { export async function getResponse(payload: ApiMessage[]): Promise { if (!settings.store.apiKey || !settings.store.endpoint || !settings.store.model) { - showToast("TriviaAI: API settings are incomplete.", Toasts.Type.FAILURE); + showToast("TriviaAI: API settings are incomplete.", "failure"); return ""; } @@ -258,7 +258,7 @@ export async function getResponse(payload: ApiMessage[]): Promise { if (!req.ok || data.error) { const errorMsg = data.error?.message ?? rawBody ?? `Status ${req.status}`; logger.error(`API Error: ${errorMsg}`); - showToast(errorMsg, Toasts.Type.FAILURE); + showToast(errorMsg, "failure"); return ""; } @@ -271,7 +271,7 @@ export async function getResponse(payload: ApiMessage[]): Promise { return response; } catch (e) { logger.error("Error getting response from AI model", e); - showToast("Error getting response from AI model", Toasts.Type.FAILURE); + showToast("Error getting response from AI model", "failure"); return ""; } } diff --git a/src/equicordplugins/userpfp/AvatarModal.tsx b/src/equicordplugins/userpfp/AvatarModal.tsx index 6e28e0544..7eeb377f1 100644 --- a/src/equicordplugins/userpfp/AvatarModal.tsx +++ b/src/equicordplugins/userpfp/AvatarModal.tsx @@ -9,7 +9,7 @@ import { Heading } from "@components/Heading"; import { Margins } from "@components/margins"; import { classNameFactory } from "@utils/css"; import { RenderModalProps } from "@vencord/discord-types"; -import { IconUtils, Modal, React, TextInput, Toasts, UserStore, useState } from "@webpack/common"; +import { IconUtils, Modal, React, showToast,TextInput, UserStore, useState } from "@webpack/common"; import { data, KEY_DATASTORE } from "."; @@ -47,11 +47,7 @@ export function SetAvatarModal({ userId, modalProps }: { userId: string; modalPr if (!file.type.startsWith("image/")) return; if (file.type === "image/gif" || file.type === "image/webp") { - Toasts.show({ - message: "GIFs/WebP must be added via URL. Upload your GIF/WebP to a image hosting service and paste the link.", - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - }); + showToast("GIFs/WebP must be added via URL. Upload your GIF/WebP to a image hosting service and paste the link.", "failure"); return; } diff --git a/src/equicordplugins/userpluginInstaller.dev/components/SettingsTab.tsx b/src/equicordplugins/userpluginInstaller.dev/components/SettingsTab.tsx index dff15dda8..631e63565 100644 --- a/src/equicordplugins/userpluginInstaller.dev/components/SettingsTab.tsx +++ b/src/equicordplugins/userpluginInstaller.dev/components/SettingsTab.tsx @@ -20,7 +20,7 @@ import { } from "@components/settings/tabs/BaseTab"; import { classes, isObjectEmpty } from "@utils/misc"; import { relaunch } from "@utils/native"; -import { Alerts, closeAllModals,NavigationRouter, Toasts, useEffect, useState } from "@webpack/common"; +import { Alerts, closeAllModals, NavigationRouter, showToast,useEffect, useState } from "@webpack/common"; import userpluginInstaller, { Native } from ".."; import { @@ -236,11 +236,7 @@ function UserPluginsTab() { setEnabled={t => { Vencord.Settings.plugins[pl.name].enabled = t; if (pluginRequiresRestart(pl)) { - Toasts.show({ - id: Toasts.genId(), - message: "Restart to apply changes!", - type: Toasts.Type.MESSAGE - }); + showToast("Restart to apply changes!", "message"); } else { (t ? startPlugin : stopPlugin)(pl); } diff --git a/src/equicordplugins/whitelistedEmojis/index.tsx b/src/equicordplugins/whitelistedEmojis/index.tsx index 05284608e..35f09ed61 100644 --- a/src/equicordplugins/whitelistedEmojis/index.tsx +++ b/src/equicordplugins/whitelistedEmojis/index.tsx @@ -12,8 +12,9 @@ import { definePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { chooseFile, saveFile } from "@utils/web"; -import { CustomEmoji, UnicodeEmoji } from "@vencord/discord-types"; -import { Alerts, Button, EmojiStore, GuildStore, IconUtils, Menu, Toasts, useEffect, useState } from "@webpack/common"; +import { CustomEmoji, ToastType, UnicodeEmoji } from "@vencord/discord-types"; +import { ToastPosition } from "@vencord/discord-types/enums"; +import { Alerts, Button, EmojiStore, GuildStore, IconUtils, Menu, showToast as originalShowToast, useEffect, useState } from "@webpack/common"; import { JSX } from "react"; import { ContextMenuEmoji, SavedEmoji, Target } from "./types"; @@ -73,14 +74,9 @@ function buildSaveData(item: ContextMenuEmoji): SavedEmoji { return saveData; } -function showToast(message: string, type = Toasts.Type.SUCCESS) { +function showToast(message: string, type: ToastType = "success") { if (settings.store.disableToasts) return; - Toasts.show({ - message, - type, - id: Toasts.genId(), - options: { duration: 3000, position: Toasts.Position.BOTTOM } - }); + originalShowToast(message, type, { duration: 3000, position: ToastPosition.BOTTOM }); } function addBulkToAllowedList(items: ContextMenuEmoji[]) { @@ -104,7 +100,7 @@ function removeBulkFromAllowedList(items: ContextMenuEmoji[]) { function addToAllowedList(item: ContextMenuEmoji) { return withWriteLock(async () => { if (itemAlreadyInList(item)) { - showToast(`"${item.name}" is already in the list`, Toasts.Type.FAILURE); + showToast(`"${item.name}" is already in the list`, "failure"); return; } @@ -116,7 +112,7 @@ function addToAllowedList(item: ContextMenuEmoji) { function removeFromAllowedList(item: ContextMenuEmoji) { return withWriteLock(async () => { if (!itemAlreadyInList(item)) { - showToast(`"${item.name}" is not in the list`, Toasts.Type.FAILURE); + showToast(`"${item.name}" is not in the list`, "failure"); return; } @@ -323,10 +319,10 @@ const importEmojis = (data: string) => withWriteLock(async () => { await setAllowedList(parsed.emojis); showToast("Successfully imported emojis"); } else { - showToast("Invalid JSON data", Toasts.Type.FAILURE); + showToast("Invalid JSON data", "failure"); } } catch (err) { - showToast(`Failed to import emojis: ${err}`, Toasts.Type.FAILURE); + showToast(`Failed to import emojis: ${err}`, "failure"); } }); diff --git a/src/plugins/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index ed543db73..8d51ae39b 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -41,7 +41,7 @@ import definePlugin from "@utils/types"; import { checkForUpdates, isOutdated, update } from "@utils/updater"; import { RenderModalProps } from "@vencord/discord-types"; import { CloudUploadPlatform } from "@vencord/discord-types/enums"; -import { Alerts, ChannelStore, CloudUploader, ConfirmModal, Constants, GuildMemberStore, openModal, Parser, PermissionsBits, PermissionStore, RelationshipStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Text, Toasts, UserStore } from "@webpack/common"; +import { Alerts, ChannelStore, CloudUploader, ConfirmModal, Constants, GuildMemberStore, openModal, Parser, PermissionsBits, PermissionStore, RelationshipStore, RestAPI, SelectedChannelStore, showToast, SnowflakeUtils, Text, UserStore } from "@webpack/common"; import { JSX } from "react"; import plugins, { PluginMeta } from "~plugins"; @@ -480,10 +480,10 @@ export default definePlugin({ } else if (pluginList && typeof pluginList === "object" && pluginList.uploadFile) { try { await uploadPluginListFile(props.channel.id, pluginList.fileContent, pluginList.filename); - showToast("Plugin list uploaded successfully!", Toasts.Type.SUCCESS); + showToast("Plugin list uploaded successfully!", "success"); } catch (e) { new Logger("SupportHelper").error("Failed to upload plugin list:", e); - showToast("Failed to upload plugin list", Toasts.Type.FAILURE); + showToast("Failed to upload plugin list", "failure"); } } }} diff --git a/src/plugins/customRPC/RpcSettings.tsx b/src/plugins/customRPC/RpcSettings.tsx index d93b18278..c06c354bd 100644 --- a/src/plugins/customRPC/RpcSettings.tsx +++ b/src/plugins/customRPC/RpcSettings.tsx @@ -15,7 +15,7 @@ import { debounce } from "@shared/debounce"; import { classNameFactory } from "@utils/css"; import { useAwaiter } from "@utils/react"; import { ActivityType } from "@vencord/discord-types/enums"; -import { Button, Select, showToast, Text, TextInput, Toasts, useState } from "@webpack/common"; +import { Button, Select, showToast, Text, TextInput, useState } from "@webpack/common"; import CustomRPCPlugin, { RpcConfig, setRpc, settings, TimestampMode } from "."; @@ -183,7 +183,7 @@ function PresetSettings({ onLoad }: { onLoad(): void; }) { await DataStore.set(PRESETS_KEY, nextPresets); setChangedPresets(nextPresets); setSelectedPreset(name); - showToast(`Saved preset ${name}.`, Toasts.Type.SUCCESS); + showToast(`Saved preset ${name}.`, "success"); } function loadPreset() { @@ -193,7 +193,7 @@ function PresetSettings({ onLoad }: { onLoad(): void; }) { Object.assign(settings.store, preset.config); onLoad(); updateRPC(); - showToast(`Loaded preset ${preset.name}.`, Toasts.Type.SUCCESS); + showToast(`Loaded preset ${preset.name}.`, "success"); } async function deletePreset() { @@ -203,7 +203,7 @@ function PresetSettings({ onLoad }: { onLoad(): void; }) { await DataStore.set(PRESETS_KEY, nextPresets); setChangedPresets(nextPresets); setSelectedPreset(""); - showToast(`Deleted preset ${selectedPreset}.`, Toasts.Type.SUCCESS); + showToast(`Deleted preset ${selectedPreset}.`, "success"); } return ( diff --git a/src/plugins/devCompanion.dev/initWs.tsx b/src/plugins/devCompanion.dev/initWs.tsx index b54218e8e..70a8e6013 100644 --- a/src/plugins/devCompanion.dev/initWs.tsx +++ b/src/plugins/devCompanion.dev/initWs.tsx @@ -11,8 +11,9 @@ import { loadLazyChunks } from "@debug/loadLazyChunks"; import { reporterData } from "@debug/reporterData"; import { getIntlMessageFromHash } from "@utils/discord"; import { canonicalizeMatch, canonicalizeReplace } from "@utils/patches"; +import { ToastPosition } from "@vencord/discord-types/enums"; import { filters, findAll, search, wreq } from "@webpack"; -import { React, Toasts, useState } from "@webpack/common"; +import { React, showToast,useState } from "@webpack/common"; import { CLIENT_VERSION, logger, PORT, settings } from "."; import { Recieve } from "./types"; @@ -65,14 +66,9 @@ export function initWs(isManual = false) { try { if (settings.store.notifyOnAutoConnect || isManual) { - Toasts.show({ - message: "Connected to WebSocket", - id: Toasts.genId(), - type: Toasts.Type.SUCCESS, - options: { - position: Toasts.Position.TOP - } - }); + showToast("Connected to WebSocket", "success", { + position: ToastPosition.TOP + }); } } catch (e) { @@ -87,14 +83,9 @@ export function initWs(isManual = false) { logger.error("Dev Companion Error:", e); - Toasts.show({ - message: "Dev Companion Error", - id: Toasts.genId(), - type: Toasts.Type.FAILURE, - options: { - position: Toasts.Position.TOP - } - }); + showToast("Dev Companion Error", "failure", { + position: ToastPosition.TOP + }); }); ws.addEventListener("close", e => { @@ -102,14 +93,9 @@ export function initWs(isManual = false) { logger.info("Dev Companion Disconnected:", e.code, e.reason); - Toasts.show({ - message: "Dev Companion Disconnected", - id: Toasts.genId(), - type: Toasts.Type.FAILURE, - options: { - position: Toasts.Position.TOP - } - }); + showToast("Dev Companion Disconnected", "failure", { + position: ToastPosition.TOP + }); }); ws.addEventListener("message", e => { diff --git a/src/plugins/devCompanion.dev/util.tsx b/src/plugins/devCompanion.dev/util.tsx index 75dedb241..6453c21f3 100644 --- a/src/plugins/devCompanion.dev/util.tsx +++ b/src/plugins/devCompanion.dev/util.tsx @@ -8,9 +8,10 @@ import { showNotice } from "@api/Notices"; import { plugins, startDependenciesRecursive, startPlugin, stopPlugin } from "@api/PluginManager"; import { Settings } from "@api/Settings"; import { canonicalizeMatch } from "@utils/patches"; +import { ToastPosition } from "@vencord/discord-types/enums"; import { Module } from "@vencord/discord-types/webpack"; import { CodeFilter, FilterFn, stringMatches, wreq } from "@webpack"; -import { Toasts } from "@webpack/common"; +import { showToast } from "@webpack/common"; import { WebpackPatcher } from "../../Vencord"; import { logger, settings as companionSettings } from "."; @@ -107,14 +108,9 @@ export function mkRegexFind(idOrSearch: string): RegExp[] { } // the next two functions are copied from components/pluginSettings function showErrorToast(message: string) { - Toasts.show({ - message, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { - position: Toasts.Position.BOTTOM - } - }); + showToast(message, "failure", { + position: ToastPosition.BOTTOM + }); } export function toggleEnabled(name: string, beforeReload: (error?: string) => void) { @@ -128,15 +124,10 @@ export function toggleEnabled(name: string, beforeReload: (error?: string) => vo beforeReload(); window.location.reload(); } - Toasts.show({ - id: Toasts.genId(), - message: "Reload Needed", - type: Toasts.Type.MESSAGE, - options: { + showToast("Reload Needed", "message", { duration: 5000, - position: Toasts.Position.TOP - } - }); + position: ToastPosition.TOP + }); } } const plugin = plugins[name]; diff --git a/src/plugins/favEmojiFirst/index.tsx b/src/plugins/favEmojiFirst/index.tsx index 2dc2bfe36..0b233cd25 100644 --- a/src/plugins/favEmojiFirst/index.tsx +++ b/src/plugins/favEmojiFirst/index.tsx @@ -19,7 +19,7 @@ import { Logger } from "@utils/Logger"; import definePlugin, { OptionType } from "@utils/types"; import { Emoji, Message } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; -import { EmojiStore, Menu, openModal,TextInput, Toasts, useEffect, useState } from "@webpack/common"; +import { EmojiStore, Menu, openModal, showToast,TextInput, useEffect, useState } from "@webpack/common"; import { ClearAliasesConfirmModal } from "./components/modals/ClearAliasesConfirmModal"; import { SetAliasModal } from "./components/modals/SetAliasModal"; @@ -700,18 +700,10 @@ async function removeAlias(alias: string) { try { await persistAliases(nextMap); - Toasts.show({ - id: Toasts.genId(), - message: `Removed alias :${alias}:`, - type: Toasts.Type.SUCCESS - }); + showToast(`Removed alias :${alias}:`, "success"); } catch (error) { logger.error("Failed to remove emoji alias.", error); - Toasts.show({ - id: Toasts.genId(), - message: "Failed to remove alias.", - type: Toasts.Type.FAILURE - }); + showToast("Failed to remove alias.", "failure"); } } @@ -720,18 +712,10 @@ async function clearAliases() { try { await persistAliases({}); - Toasts.show({ - id: Toasts.genId(), - message: "Deleted all emoji aliases.", - type: Toasts.Type.SUCCESS - }); + showToast("Deleted all emoji aliases.", "success"); } catch (error) { logger.error("Failed to clear emoji aliases.", error); - Toasts.show({ - id: Toasts.genId(), - message: "Failed to delete aliases.", - type: Toasts.Type.FAILURE - }); + showToast("Failed to delete aliases.", "failure"); } } @@ -750,11 +734,7 @@ function openSetAliasModal(ref: StoredEmojiRef) { onSave={async input => { const result = await saveAlias(input, ref); if (!result.ok) return result; - Toasts.show({ - id: Toasts.genId(), - message: `Alias set for ${getEmojiDisplayName(ref)}.`, - type: Toasts.Type.SUCCESS - }); + showToast(`Alias set for ${getEmojiDisplayName(ref)}.`, "success"); return result; }} /> diff --git a/src/plugins/messageClickActions/index.ts b/src/plugins/messageClickActions/index.ts index 95ee7fe5c..dedf5121d 100644 --- a/src/plugins/messageClickActions/index.ts +++ b/src/plugins/messageClickActions/index.ts @@ -13,7 +13,7 @@ import { Logger } from "@utils/Logger"; import definePlugin, { makeRange, OptionType } from "@utils/types"; import type { Channel, Message } from "@vencord/discord-types"; import { ApplicationIntegrationType, MessageFlags } from "@vencord/discord-types/enums"; -import { AuthenticationStore, Constants, EditMessageStore, FluxDispatcher, MessageActions, MessageTypeSets, PermissionsBits, PermissionStore, PinActions, RestAPI, Toasts, WindowStore } from "@webpack/common"; +import { AuthenticationStore, Constants, EditMessageStore, FluxDispatcher, MessageActions, MessageTypeSets, PermissionsBits, PermissionStore, PinActions, RestAPI, showToast,WindowStore } from "@webpack/common"; import { AdditionalReactEmojisSetting, MAX_ADDITIONAL_REACT_EMOJIS, ReactEmojiSetting } from "./ReactEmojiSetting"; @@ -256,14 +256,9 @@ export const settings = definePluginSettings({ }); function showWarning(message: string) { - Toasts.show({ - message, - type: Toasts.Type.FAILURE, - id: Toasts.genId(), - options: { + showToast(message, "failure", { duration: 3000 - } - }); + }); } function clearClickTimeouts() {