From 19246845448185d617f60daea26b3003420ee0b5 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Mon, 18 May 2026 11:11:21 -0400 Subject: [PATCH] migrate and fix a bunch of test issues because of deprecations --- src/components/ThemeSettings/ThemesTab.tsx | 3 +- src/components/ThemeSettings/UserCSSModal.tsx | 34 +- .../tabs/plugins/ContributorModal.css | 13 +- .../tabs/plugins/ContributorModal.tsx | 68 ++-- src/equicordplugins/baseDecoder/index.tsx | 49 +-- .../components/BookmarkContainer.tsx | 3 +- .../channelTabs/components/ContextMenus.tsx | 345 ++++++++-------- .../commandPalette/CommandPicker.tsx | 12 +- src/equicordplugins/commandPalette/ui.tsx | 2 +- .../commandPalette/ui/CommandPaletteModal.tsx | 16 +- .../customFolderIcons/components.tsx | 22 +- .../customUserColors/SetColorModal.tsx | 55 ++- .../customUserColors/index.tsx | 3 +- .../findReply/ReplyNavigator.tsx | 7 +- src/equicordplugins/friendshipRanks/index.tsx | 29 +- .../ghosted/GhostedUsersModal.tsx | 138 +++---- src/equicordplugins/ghosted/index.tsx | 6 +- .../gifCollections/components/modals.tsx | 174 ++++---- .../components/ProfilePopoutComponent.tsx | 3 +- .../components/ProfileTabComponent.tsx | 3 +- .../githubRepos/components/ReposModal.tsx | 80 ++-- .../globalBadges/badgeModal.tsx | 44 +- .../components/HiddenServersMenu.tsx | 31 +- .../iconViewer/components/Modals.tsx | 110 +++-- .../inRole/RoleMembersModal.tsx | 55 ++- .../components/DecryptionModal.tsx | 82 ++-- .../components/EncryptionModal.tsx | 138 +++---- .../components/CommandPalette.tsx | 12 +- .../components/MultipleChoice.tsx | 13 +- .../components/TextInput.tsx | 27 +- .../keyboardNavigation/index.tsx | 3 +- .../loginWithQR/ui/modals/QrModal.tsx | 5 +- .../loginWithQR/ui/modals/VerifyModal.tsx | 30 +- .../components/LogsModal.tsx | 188 +++++---- .../moreStickers/components/picker.tsx | 15 +- .../spotify/lyrics/components/lyrics.tsx | 3 +- .../spotify/lyrics/components/modal.tsx | 99 +++-- .../tidal/lyrics/components/lyrics.tsx | 3 +- .../tidal/lyrics/components/modal.tsx | 83 ++-- .../newPluginsManager/NewPluginsModal.tsx | 96 +++-- .../profileSets/components/confirmModal.tsx | 96 +++-- .../profileSets/components/presetManager.tsx | 3 +- .../questify/components/settingsModal.tsx | 2 +- src/equicordplugins/quoter/index.tsx | 91 ++--- .../recentDMSwitcher/index.tsx | 3 +- src/equicordplugins/remix/RemixModal.tsx | 43 +- src/equicordplugins/remix/index.tsx | 3 +- .../components/ScheduleTimeModal.tsx | 142 +++---- .../components/ViewScheduledModal.tsx | 128 +++--- .../sekaiStickers/Components/Picker.tsx | 34 +- .../Components/SekaiStickersModal.tsx | 83 ++-- src/equicordplugins/sekaiStickers/index.tsx | 2 +- src/equicordplugins/soggy/index.tsx | 11 +- .../songSpotlight.desktop/lib/oauth2.tsx | 3 +- .../ui/settings/AddSong.tsx | 113 +++--- .../ui/settings/index.tsx | 21 +- src/equicordplugins/statusPresets/index.tsx | 3 +- .../streaks/stores/AuthorizationStore.tsx | 3 +- .../themeLibrary/components/ThemeCard.tsx | 55 ++- .../components/ThemeInfoModal.tsx | 376 +++++++++--------- src/equicordplugins/themeLibrary/types.ts | 5 +- .../themeLibrary/utils/auth.tsx | 3 +- .../timezones/TimezoneModal.tsx | 116 +++--- src/equicordplugins/timezones/index.tsx | 3 +- src/equicordplugins/userpfp/AvatarModal.tsx | 55 +-- src/equicordplugins/userpfp/index.tsx | 3 +- .../components/SettingsTab.tsx | 3 +- .../vcNarratorCustom/index.tsx | 151 ++++--- src/equicordplugins/viewRawVariant/index.tsx | 68 ++-- .../VoiceChannelLogEntryComponent.tsx | 3 +- .../components/VoiceChannelLogModal.tsx | 70 ++-- .../voiceMessageTranscriber.desktop/index.tsx | 207 +++++----- src/equicordplugins/webpackTarball/index.tsx | 114 +++--- src/equicordplugins/zipPreview/components.tsx | 82 ++-- .../modals/ClearAliasesConfirmModal.tsx | 38 +- .../components/modals/SetAliasModal.tsx | 68 ++-- .../favEmojiFirst/components/modals/types.ts | 6 +- src/plugins/favEmojiFirst/index.tsx | 3 +- .../messageClickActions/ReactEmojiSetting.tsx | 14 +- src/plugins/serverInfo/GuildInfoModal.tsx | 1 - src/plugins/showMeYourName/index.tsx | 107 +++-- src/plugins/translate/TranslateIcon.tsx | 1 - src/plugins/translate/TranslateModal.tsx | 2 +- src/plugins/viewRaw/index.tsx | 2 - 84 files changed, 2106 insertions(+), 2336 deletions(-) diff --git a/src/components/ThemeSettings/ThemesTab.tsx b/src/components/ThemeSettings/ThemesTab.tsx index 2c4a734c9..529f6b009 100644 --- a/src/components/ThemeSettings/ThemesTab.tsx +++ b/src/components/ThemeSettings/ThemesTab.tsx @@ -37,7 +37,6 @@ import { classNameFactory } from "@utils/css"; import { copyWithToast, openInviteModal } from "@utils/discord"; import { Margins } from "@utils/margins"; import { classes } from "@utils/misc"; -import { openModal } from "@utils/modal"; import { relaunch, showItemInFolder } from "@utils/native"; import { useAwaiter, useForceUpdater } from "@utils/react"; import type { ThemeHeader } from "@utils/themes"; @@ -45,7 +44,7 @@ import { getThemeInfo, stripBOM, type UserThemeHeader } from "@utils/themes/bd"; import { usercssParse } from "@utils/themes/usercss"; import { getStylusWebStoreUrl } from "@utils/web"; import { findComponentByCodeLazy, findLazy } from "@webpack"; -import { Alerts, Menu, React, Select, showToast, TextInput, Toasts, Tooltip, useEffect, useMemo, useState } from "@webpack/common"; +import { Alerts, Menu, openModal,React, Select, showToast, TextInput, Toasts, Tooltip, useEffect, useMemo, useState } from "@webpack/common"; import { ContextMenuApi } from "@webpack/common/menu"; import type { ComponentType, Ref, SyntheticEvent } from "react"; import type { UserstyleHeader } from "usercss-meta"; diff --git a/src/components/ThemeSettings/UserCSSModal.tsx b/src/components/ThemeSettings/UserCSSModal.tsx index c517a7639..550eeb877 100644 --- a/src/components/ThemeSettings/UserCSSModal.tsx +++ b/src/components/ThemeSettings/UserCSSModal.tsx @@ -9,9 +9,8 @@ import { BaseText } from "@components/BaseText"; import { Flex } from "@components/Flex"; import { CopyIcon, PasteIcon, ResetIcon } from "@components/Icons"; import { copyWithToast } from "@utils/discord"; -import { ModalCloseButton, ModalContent, ModalHeader, ModalRoot } from "@utils/modal"; import { RenderModalProps } from "@vencord/discord-types"; -import { showToast, Toasts, Tooltip } from "@webpack/common"; +import { Modal, showToast, Toasts, Tooltip } from "@webpack/common"; import { type ReactNode } from "react"; import { UserstyleHeader } from "usercss-meta"; @@ -187,21 +186,22 @@ export function UserCSSSettingsModal({ modalProps, theme, onSettingsReset }: Use } return ( - - - Settings for {theme.name} - - - - + + Settings for {theme.name} + + + + + - - - - - {controls} - - - + } + > + + {controls} + + ); } diff --git a/src/components/settings/tabs/plugins/ContributorModal.css b/src/components/settings/tabs/plugins/ContributorModal.css index d46c90d7f..0e453e2ed 100644 --- a/src/components/settings/tabs/plugins/ContributorModal.css +++ b/src/components/settings/tabs/plugins/ContributorModal.css @@ -1,12 +1,12 @@ .vc-author-modal-root { - padding: 1em; + padding: 0 0 16px; } .vc-author-modal-header { display: flex; align-items: center; gap: 8px; - margin-bottom: 1em; + margin-bottom: 4px; } .vc-author-modal-name { @@ -50,18 +50,21 @@ 0 2px 6px rgb(0 0 0 / 35%); } -.vc-author-modal-root + [class*="footer"] { - padding: 16px; +div:has(.vc-author-modal-root) > [class*="actionBar"] { + padding: 8px 16px; + min-height: unset; } .vc-author-modal-links { display: flex; gap: 4px; margin-left: auto; + width: 100%; + justify-content: flex-end; } .vc-author-modal-plugins { display: grid; gap: 0.5em; margin-top: 0.75em; -} \ No newline at end of file +} diff --git a/src/components/settings/tabs/plugins/ContributorModal.tsx b/src/components/settings/tabs/plugins/ContributorModal.tsx index 246bdae28..273a27eef 100644 --- a/src/components/settings/tabs/plugins/ContributorModal.tsx +++ b/src/components/settings/tabs/plugins/ContributorModal.tsx @@ -13,7 +13,7 @@ import { Paragraph } from "@components/Paragraph"; import { EquicordDevsById, VencordDevsById } from "@utils/constants"; import { classNameFactory } from "@utils/css"; import { fetchUserProfile } from "@utils/discord"; -import { classes, pluralise } from "@utils/misc"; +import { pluralise } from "@utils/misc"; import { RenderModalProps, User } from "@vencord/discord-types"; import { Modal, openModal, showToast, useEffect, useMemo, UserProfileStore, useStateFromStores } from "@webpack/common"; @@ -63,7 +63,7 @@ function ContributorModal({ user, modalProps }: { user: User; modalProps: Render +
) } + actionBarInput={ + hasLinks && ( +
+ {website && ( + + )} + {githubName && ( + + )} +
+ ) + } > - {!!plugins.length && ( -
- {plugins.map(p => - showToast("Restart to apply changes!")} - /> - )} -
- )} - - {hasLinks && ( -
- {website && ( - - )} - {githubName && ( - - )} -
- )} +
+ {!!plugins.length && ( +
+ {plugins.map(p => + showToast("Restart to apply changes!")} + /> + )} +
+ )} +
); } diff --git a/src/equicordplugins/baseDecoder/index.tsx b/src/equicordplugins/baseDecoder/index.tsx index 9ecb51a9e..0c6466e84 100644 --- a/src/equicordplugins/baseDecoder/index.tsx +++ b/src/equicordplugins/baseDecoder/index.tsx @@ -17,16 +17,13 @@ */ import { definePluginSettings } from "@api/Settings"; -import { BaseText } from "@components/BaseText"; import { CodeBlock } from "@components/CodeBlock"; import ErrorBoundary from "@components/ErrorBoundary"; -import { Flex } from "@components/Flex"; import { Heading } from "@components/Heading"; import { EquicordDevs } from "@utils/constants"; import { copyWithToast } from "@utils/discord"; -import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; -import { Button, ChannelStore } from "@webpack/common"; +import { ChannelStore, Modal, openModal } from "@webpack/common"; function DecodeIcon() { return ( @@ -64,32 +61,26 @@ function decodeBase64Strings(base64Strings) { } function openDecodedBase64Modal(decodedContent) { - const key = openModal(props => ( + openModal(props => ( - - - Decoded Base64 Content - closeModal(key)} /> - - -
- Decoded Content - {decodedContent.map((content, index) => ( - - ))} -
-
- - - {decodedContent.map((content, index) => ( - - ))} - - -
-
+ ({ + text: `Copy Decoded Content ${index + 1}`, + variant: "primary", + onClick: () => copyWithToast(content, "Decoded content copied to clipboard!") + }))} + > +
+ Decoded Content + {decodedContent.map((content, index) => ( + + ))} +
+
+ )); } diff --git a/src/equicordplugins/channelTabs/components/BookmarkContainer.tsx b/src/equicordplugins/channelTabs/components/BookmarkContainer.tsx index b671049b8..16c46575e 100644 --- a/src/equicordplugins/channelTabs/components/BookmarkContainer.tsx +++ b/src/equicordplugins/channelTabs/components/BookmarkContainer.tsx @@ -10,9 +10,8 @@ import { CircleQuestionIcon, DiscoveryIcon, EnvelopeIcon, FriendsIcon, NitroIcon import { classNameFactory } from "@utils/css"; import { getGuildAcronym, getIntlMessage } from "@utils/discord"; import { classes } from "@utils/misc"; -import { closeModal, openModal } from "@utils/modal"; import { findComponentByCodeLazy } from "@webpack"; -import { Avatar, ChannelStore, ContextMenuApi, FluxDispatcher, GuildStore, Menu, React, ReadStateStore, ReadStateUtils, SelectedChannelStore, SelectedGuildStore, TextInput, Tooltip, useDrag, useDrop, useEffect, useRef, UserStore, useState } from "@webpack/common"; +import { Avatar, ChannelStore, closeModal, ContextMenuApi, FluxDispatcher, GuildStore, Menu, openModal,React, ReadStateStore, ReadStateUtils, SelectedChannelStore, SelectedGuildStore, TextInput, Tooltip, useDrag, useDrop, useEffect, useRef, UserStore, useState } from "@webpack/common"; import { NotificationDot } from "./ChannelTab"; import { BookmarkContextMenu, EditModal } from "./ContextMenus"; diff --git a/src/equicordplugins/channelTabs/components/ContextMenus.tsx b/src/equicordplugins/channelTabs/components/ContextMenus.tsx index 9a1072016..6efab55d0 100644 --- a/src/equicordplugins/channelTabs/components/ContextMenus.tsx +++ b/src/equicordplugins/channelTabs/components/ContextMenus.tsx @@ -11,8 +11,8 @@ import { bookmarkFolderColors, bookmarkPlaceholderName, closeOtherTabs, closeTab import { Bookmark, BookmarkFolder, Bookmarks, ChannelTabsProps, UseBookmarkMethods } from "@equicordplugins/channelTabs/util/types"; import { getIntlMessage } from "@utils/discord"; import { Margins } from "@utils/margins"; -import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; -import { Button, ChannelStore, ColorPicker, FluxDispatcher, Menu, ReadStateStore, ReadStateUtils, Select, TextInput, useMemo, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Button, ChannelStore, closeModal, ColorPicker, FluxDispatcher, Menu, Modal, openModal, ReadStateStore, ReadStateUtils, Select, TextInput, useMemo, useState } from "@webpack/common"; const legacyFolderColors: Record = { "var(--channeltabs-red)": bookmarkFolderColors.Red, @@ -115,7 +115,7 @@ function FolderChipPreview({ name, color, iconName }: { name: string; color: str } function FolderIconPickerModal({ modalProps, modalKey, name, color, iconName, onSelect, onColorChange }: { - modalProps: ModalProps, + modalProps: RenderModalProps, modalKey: string, name: string, color: string, @@ -133,73 +133,72 @@ function FolderIconPickerModal({ modalProps, modalKey, name, color, iconName, on }, [iconNames, search]); return ( - - - Choose Folder Icon - - - Preview - - Icon Color -
- { - const nextColor = intToColor(value); - setLocalColor(nextColor); - onColorChange(nextColor); - }} - showEyeDropper={false} - /> -
- Search - Choose Folder Icon} + actions={[ + { + text: "Close", + variant: "secondary", + onClick: () => closeModal(modalKey) + } + ]} + > + Preview + + Icon Color +
+ { + const nextColor = intToColor(value); + setLocalColor(nextColor); + onColorChange(nextColor); + }} + showEyeDropper={false} /> -
- {filteredIconNames.map(name => ( - - ))} -
- - - - - +
+ Search + +
+ {filteredIconNames.map(name => ( + + ))} +
+ ); } @@ -263,7 +262,7 @@ function FolderAppearanceFields({ } export function EditModal({ modalProps, modalKey, bookmark, onSave }: { - modalProps: ModalProps, + modalProps: RenderModalProps, modalKey: string, bookmark: Bookmark | BookmarkFolder, onSave: (name: string, color: string, iconName?: string) => void; @@ -274,46 +273,47 @@ export function EditModal({ modalProps, modalKey, bookmark, onSave }: { const placeholder = bookmarkPlaceholderName(bookmark); return ( - - - Edit Bookmark - - - {isBookmarkFolder(bookmark) - ? Edit Bookmark} + actions={[ + { + text: "Save", + variant: "primary", + onClick: () => onSave(name || placeholder, color, iconName) + }, + { + text: "Cancel", + variant: "secondary", + onClick: () => closeModal(modalKey) + } + ]} + > + {isBookmarkFolder(bookmark) + ? + : <> + Bookmark Name + - : <> - Bookmark Name - - } - - - - - - + } + ); } function AddToFolderModal({ modalProps, modalKey, bookmarks, onSave }: { - modalProps: any, + modalProps: RenderModalProps, modalKey: string, bookmarks: Bookmarks, onSave: (folderIndex: number, folderName: string, folderColor: string, iconName?: string) => void; @@ -324,78 +324,79 @@ function AddToFolderModal({ modalProps, modalKey, bookmarks, onSave }: { const [iconName, setIconName] = useState(); return ( - - - Add Bookmark to Folder - - - Select a folder - isBookmarkFolder(bookmark)) + .map(([index, bookmark]) => ({ + label: bookmark.name, + value: parseInt(index, 10) + })), + { + label: "Create one", + value: -1, + default: true + }]} + isSelected={v => v === folderIndex} + select={setIndex} + serialize={String} + /> + {folderIndex === -1 && } + ); } -function DeleteFolderConfirmationModal({ modalProps, modalKey, onConfirm }) { +function DeleteFolderConfirmationModal({ modalProps, modalKey, onConfirm }: { + modalProps: RenderModalProps, + modalKey: string, + onConfirm: () => void; +}) { return ( - - - Are you sure? - - - - Deleting a bookmark folder will also delete all bookmarks within it. - - - - - - - + Are you sure?} + actions={[ + { + text: "Delete", + variant: "critical-primary", + onClick: onConfirm + }, + { + text: "Cancel", + variant: "secondary", + onClick: () => closeModal(modalKey) + } + ]} + > + + Deleting a bookmark folder will also delete all bookmarks within it. + + ); } diff --git a/src/equicordplugins/commandPalette/CommandPicker.tsx b/src/equicordplugins/commandPalette/CommandPicker.tsx index 9ff4db0b6..746e6eeec 100644 --- a/src/equicordplugins/commandPalette/CommandPicker.tsx +++ b/src/equicordplugins/commandPalette/CommandPicker.tsx @@ -7,8 +7,8 @@ import { CogWheel } from "@components/Icons"; import { classNameFactory } from "@utils/css"; import { classes } from "@utils/misc"; -import { type ModalProps,ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { TextInput, useCallback, useEffect, useMemo, useRef, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal,openModal, TextInput, useCallback, useEffect, useMemo, useRef, useState } from "@webpack/common"; import { type CommandEntry, getCategoryGroupLabel, getCategoryWeight, getCommandSearchText, getRecentRank, getRegistryVersion, listCommands, subscribeRegistry @@ -56,7 +56,7 @@ export function openCommandPicker(props: CommandPickerProps) { )); } -function CommandPickerModal({ modalProps, commands: providedCommands, allowMultiple = false, initialQuery = "", initialSelectedIds = [], includeHiddenInSearch = false, emptyStateText = "No commands found", filter: filterPredicate, onSelect, onComplete, onClose }: CommandPickerProps & { modalProps: ModalProps; }) { +function CommandPickerModal({ modalProps, commands: providedCommands, allowMultiple = false, initialQuery = "", initialSelectedIds = [], includeHiddenInSearch = false, emptyStateText = "No commands found", filter: filterPredicate, onSelect, onComplete, onClose }: CommandPickerProps & { modalProps: RenderModalProps; }) { const [query, setQuery] = useState(initialQuery); const [registryVersion, setRegistryVersion] = useState(() => getRegistryVersion()); const [selectedIndex, setSelectedIndex] = useState(-1); @@ -321,8 +321,8 @@ function CommandPickerModal({ modalProps, commands: providedCommands, allowMulti }; return ( - -
+ +
- + ); } diff --git a/src/equicordplugins/commandPalette/ui.tsx b/src/equicordplugins/commandPalette/ui.tsx index 1ddf1233e..7f1ad3f32 100644 --- a/src/equicordplugins/commandPalette/ui.tsx +++ b/src/equicordplugins/commandPalette/ui.tsx @@ -4,7 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { closeModal, openModal } from "@utils/modal"; +import { closeModal, openModal } from "@webpack/common"; import { CommandPaletteModal } from "./ui/CommandPaletteModal"; diff --git a/src/equicordplugins/commandPalette/ui/CommandPaletteModal.tsx b/src/equicordplugins/commandPalette/ui/CommandPaletteModal.tsx index d531a8c18..e6d442f6d 100644 --- a/src/equicordplugins/commandPalette/ui/CommandPaletteModal.tsx +++ b/src/equicordplugins/commandPalette/ui/CommandPaletteModal.tsx @@ -11,8 +11,8 @@ import { classNameFactory, classNameToSelector } from "@utils/css"; import { copyWithToast } from "@utils/discord"; import { Logger } from "@utils/Logger"; import { classes } from "@utils/misc"; -import { type ModalProps, ModalRoot, ModalSize } from "@utils/modal"; -import { TextInput, Toasts, useEffect, useMemo, useRef, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal,TextInput, Toasts, useEffect, useMemo, useRef, useState } from "@webpack/common"; import type { KeyboardEvent as ReactKeyboardEvent } from "react"; import { buildQueryResolution } from "../actions/executors"; @@ -282,7 +282,7 @@ function createInitialPageState(ref: PalettePageRef): PalettePageValuesState { }; } -export function CommandPaletteModal({ modalProps, instanceKey }: { modalProps: ModalProps; instanceKey: number; }) { +export function CommandPaletteModal({ modalProps, instanceKey }: { modalProps: RenderModalProps; instanceKey: number; }) { const { compactStartEnabled = true, closeAfterExecute = true @@ -1469,12 +1469,12 @@ export function CommandPaletteModal({ modalProps, instanceKey }: { modalProps: M }, [activePage, activePageFieldKey, activePageSpec, activePageState, activePageSuggestions]); return ( - -
+
{!isPageOpen && ( )}
- + ); } diff --git a/src/equicordplugins/customFolderIcons/components.tsx b/src/equicordplugins/customFolderIcons/components.tsx index b5feb52a7..1509e2288 100644 --- a/src/equicordplugins/customFolderIcons/components.tsx +++ b/src/equicordplugins/customFolderIcons/components.tsx @@ -4,8 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { closeModal, ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal"; -import { Button, Menu, Slider, TextInput, useState } from "@webpack/common"; +import { Button, closeModal, Menu, Modal,openModalLazy, Slider, TextInput, useState } from "@webpack/common"; import { folderIconsData, settings } from "./settings"; import { folderProp, int2rgba, setFolderData } from "./util"; @@ -95,17 +94,12 @@ export function makeContextItem(a: folderProp) { action={() => { openModalLazy(async () => { return props => ( - - -
- Set a New Icon. -
-
- - - + +
You might have to hover the folder after setting in order for it to refresh.
-
+ ); }, { diff --git a/src/equicordplugins/customUserColors/SetColorModal.tsx b/src/equicordplugins/customUserColors/SetColorModal.tsx index ba51afa70..c57ce4b63 100644 --- a/src/equicordplugins/customUserColors/SetColorModal.tsx +++ b/src/equicordplugins/customUserColors/SetColorModal.tsx @@ -5,17 +5,17 @@ */ import { set } from "@api/DataStore"; -import { HeadingPrimary, HeadingSecondary } from "@components/Heading"; +import { HeadingSecondary } from "@components/Heading"; import { classNameFactory } from "@utils/css"; import { Margins } from "@utils/margins"; -import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot } from "@utils/modal"; -import { Button, ColorPicker, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { ColorPicker, Modal, React, useState } from "@webpack/common"; import { colors, DATASTORE_KEY } from "./index"; const cl = classNameFactory("vc-customColors-"); -export function SetColorModal({ id, modalProps }: { id: string, modalProps: ModalProps; }) { +export function SetColorModal({ id, modalProps }: { id: string, modalProps: RenderModalProps; }) { const initialColor = parseInt(colors[id], 16) || 372735; // color picker default to current color set for user (if null it's 0x05afff :3 ) @@ -26,7 +26,7 @@ export function SetColorModal({ id, modalProps }: { id: string, modalProps: Moda setColorPickerColor(color); } - function handleKey(e: KeyboardEvent) { + function handleKey(e: React.KeyboardEvent) { if (e.key === "Enter") saveUserColor(); } @@ -44,14 +44,24 @@ export function SetColorModal({ id, modalProps }: { id: string, modalProps: Moda } return ( - - - - Custom Color - - - - + +
Pick a Color @@ -62,22 +72,7 @@ export function SetColorModal({ id, modalProps }: { id: string, modalProps: Moda showEyeDropper={false} />
- - - - - - - +
+
); } diff --git a/src/equicordplugins/customUserColors/index.tsx b/src/equicordplugins/customUserColors/index.tsx index 55f92cf3f..92cc03da8 100644 --- a/src/equicordplugins/customUserColors/index.tsx +++ b/src/equicordplugins/customUserColors/index.tsx @@ -10,11 +10,10 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { get } from "@api/DataStore"; import { definePluginSettings, Settings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; -import { openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; import { Channel, User } from "@vencord/discord-types"; import { extractAndLoadChunksLazy } from "@webpack"; -import { ChannelStore, Menu, SelectedChannelStore } from "@webpack/common"; +import { ChannelStore, Menu, openModal,SelectedChannelStore } from "@webpack/common"; import { SetColorModal } from "./SetColorModal"; diff --git a/src/equicordplugins/findReply/ReplyNavigator.tsx b/src/equicordplugins/findReply/ReplyNavigator.tsx index 1c656d1ce..c5aa6b158 100644 --- a/src/equicordplugins/findReply/ReplyNavigator.tsx +++ b/src/equicordplugins/findReply/ReplyNavigator.tsx @@ -8,10 +8,11 @@ import "./styles.css"; import ErrorBoundary from "@components/ErrorBoundary"; import { Paginator, requirePaginator } from "@plugins/reviewDB/components/ReviewModal"; -import { ModalCloseButton } from "@utils/modal"; import { Message } from "@vencord/discord-types"; -import { findCssClassesLazy } from "@webpack"; +import { findComponentByCodeLazy, findCssClassesLazy } from "@webpack"; import { React, useRef, useState } from "@webpack/common"; + +const CloseButton = findComponentByCodeLazy("CLOSE_BUTTON_LABEL"); import { MutableRefObject } from "react"; import { jumper } from "./index"; @@ -53,7 +54,7 @@ export default function ReplyNavigator({ replies }: { replies: Message[]; }) { totalCount={replies.length} onPageChange={processPageChange} /> - setVisible(false)} /> + setVisible(false)} />
); diff --git a/src/equicordplugins/friendshipRanks/index.tsx b/src/equicordplugins/friendshipRanks/index.tsx index c33b57b9e..5b777f009 100644 --- a/src/equicordplugins/friendshipRanks/index.tsx +++ b/src/equicordplugins/friendshipRanks/index.tsx @@ -13,9 +13,9 @@ import { Flex } from "@components/Flex"; import { Paragraph } from "@components/Paragraph"; import { Devs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; -import { ModalContent, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin from "@utils/types"; -import { Forms, RelationshipStore } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Forms, Modal,openModal, RelationshipStore } from "@webpack/common"; interface rankInfo { title: string; @@ -84,10 +84,12 @@ const ranks: rankInfo[] = ]; function openRankModal(rank: rankInfo) { - openModal(props => ( + openModal((props: RenderModalProps) => ( - - + - - -
- - {rank.description} - -
-
-
+ } + > +
+ + {rank.description} + +
+
)); } diff --git a/src/equicordplugins/ghosted/GhostedUsersModal.tsx b/src/equicordplugins/ghosted/GhostedUsersModal.tsx index eb85658b5..ade418e6a 100644 --- a/src/equicordplugins/ghosted/GhostedUsersModal.tsx +++ b/src/equicordplugins/ghosted/GhostedUsersModal.tsx @@ -5,10 +5,9 @@ */ import { classNameFactory } from "@utils/css"; -import { ModalCloseButton, ModalContent, ModalHeader, ModalRoot, ModalSize } from "@utils/modal"; -import { Channel } from "@vencord/discord-types"; +import { Channel, RenderModalProps } from "@vencord/discord-types"; import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; -import { Avatar, Button, ChannelStore, MessageStore, React, Text, UserStore } from "@webpack/common"; +import { Avatar, Button, ChannelStore, MessageStore, Modal,React, Text, UserStore } from "@webpack/common"; const cl = classNameFactory("vc-boo-"); @@ -37,9 +36,8 @@ function GroupDmsIcon({ channel }: { channel: Channel; }) { } interface GhostedUsersModalProps { - modalProps: any; + modalProps: RenderModalProps; ghostedChannels: string[]; - onClose: () => void; onClearGhost: (channelId: string) => void; } @@ -57,14 +55,14 @@ export function getChannelDisplayName(channelId: string): string { return user?.username || "Unknown User"; } -export function GhostedUsersModal({ modalProps, ghostedChannels: initialChannels, onClose, onClearGhost }: GhostedUsersModalProps) { +export function GhostedUsersModal({ modalProps, ghostedChannels: initialChannels, onClearGhost }: GhostedUsersModalProps) { const [ghostedChannels, setGhostedChannels] = React.useState(initialChannels); const handleChannelClick = (channelId: string) => { const channel = ChannelStore.getChannel(channelId); if (channel) { SelectedChannelActionCreators.selectPrivateChannel(channelId); - onClose(); + modalProps.onClose(); } }; @@ -83,77 +81,67 @@ export function GhostedUsersModal({ modalProps, ghostedChannels: initialChannels }; return ( - - - - Ghosted Users ({ghostedChannels.length}) - - {ghostedChannels.length > 0 && ( - - )} - - - -
- {ghostedChannels.length === 0 ? ( - No ghosts here! - ) : ( - ghostedChannels.map(channelId => { - const channel = ChannelStore.getChannel(channelId); - if (!channel) return null; + 0 ? [ + { + text: "Clear All", + variant: "primary", + onClick: handleClearAll + } + ] : []} + > +
+ {ghostedChannels.length === 0 ? ( + No ghosts here! + ) : ( + ghostedChannels.map(channelId => { + const channel = ChannelStore.getChannel(channelId); + if (!channel) return null; - const lastMessage = MessageStore.getMessages(channelId)?.last(); - const lastMessageDate = lastMessage?.timestamp ? formatMessageDate(lastMessage.timestamp) : ""; + const lastMessage = MessageStore.getMessages(channelId)?.last(); + const lastMessageDate = lastMessage?.timestamp ? formatMessageDate(lastMessage.timestamp) : ""; - const displayName = getChannelDisplayName(channel.id); - const userId = channel?.recipients?.[0] ?? ""; - return ( -
handleChannelClick(channelId)} - className={cl("ghosted-entry")} - > - {channel.isGroupDM() ? - : } -
- - {displayName} + const displayName = getChannelDisplayName(channel.id); + const userId = channel?.recipients?.[0] ?? ""; + return ( +
handleChannelClick(channelId)} + className={cl("ghosted-entry")} + > + {channel.isGroupDM() ? + : } +
+ + {displayName} + + {lastMessageDate && ( + + {lastMessageDate} - {lastMessageDate && ( - - {lastMessageDate} - - )} -
- + )}
- ); - }) - )} -
- - + +
+ ); + }) + )} +
+
); } diff --git a/src/equicordplugins/ghosted/index.tsx b/src/equicordplugins/ghosted/index.tsx index ca2b504d9..092316212 100644 --- a/src/equicordplugins/ghosted/index.tsx +++ b/src/equicordplugins/ghosted/index.tsx @@ -12,10 +12,9 @@ import { definePluginSettings } from "@api/Settings"; import ErrorBoundary from "@components/ErrorBoundary"; import { Devs, EquicordDevs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; -import { closeModal, openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; import { Channel } from "@vencord/discord-types"; -import { Menu, Tooltip, useEffect, useState } from "@webpack/common"; +import { Menu, openModal,Tooltip, useEffect, useState } from "@webpack/common"; import { Boo, clearChannelFromGhost, getBooCount, getGhostedChannels, onBooCountChange } from "./Boo"; import { getChannelDisplayName, GhostedUsersModal } from "./GhostedUsersModal"; @@ -85,12 +84,11 @@ function BooIndicator() { const handleClick = () => { const ghostedChannels = getGhostedChannels(); - const modalKey = openModal(modalProps => ( + openModal(modalProps => ( closeModal(modalKey)} onClearGhost={clearChannelFromGhost} /> diff --git a/src/equicordplugins/gifCollections/components/modals.tsx b/src/equicordplugins/gifCollections/components/modals.tsx index 3e36e52b6..7647544ff 100644 --- a/src/equicordplugins/gifCollections/components/modals.tsx +++ b/src/equicordplugins/gifCollections/components/modals.tsx @@ -8,8 +8,8 @@ import { Flex } from "@components/Flex"; import { Heading } from "@components/Heading"; import { Paragraph } from "@components/Paragraph"; import { classes } from "@utils/misc"; -import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { Button, FluxDispatcher, TextInput, useCallback, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Button, FluxDispatcher, Modal, openModal, TextInput, useCallback, useState } from "@webpack/common"; import { settings } from "../settings"; import { Collection, Gif } from "../types"; @@ -49,124 +49,116 @@ export function openRenameCollectionModal(name: string) { openModal(props => ); } -function InfoModal({ props, title, rows }: { props: ModalProps; title: string; rows: { label: string; value: string; }[]; }) { +function InfoModal({ props, title, rows }: { props: RenderModalProps; title: string; rows: { label: string; value: string; }[]; }) { return ( - - - {title} - - -
- {rows.map(row => ( - - {row.label} - {row.value} - + +
+ {rows.map(row => ( + + {row.label} + {row.value} + + ))} +
+
+ ); +} + +function MoveToCollectionModal({ props, gifId }: { props: RenderModalProps; gifId: string; }) { + return ( + + Select a collection to move the item to +
+ {cache_collections + .filter(col => col.name !== getItemCollectionNameFromId(gifId)) + .map(col => ( + ))} -
-
- - - -
+
+ ); } -function MoveToCollectionModal({ props, gifId }: { props: ModalProps; gifId: string; }) { - return ( - - - Move To Collection - - - Select a collection to move the item to -
- {cache_collections - .filter(col => col.name !== getItemCollectionNameFromId(gifId)) - .map(col => ( - - ))} -
-
- - - -
- ); -} - -function CreateCollectionModal({ props, gif }: { props: ModalProps; gif: Gif; }) { +function CreateCollectionModal({ props, gif }: { props: RenderModalProps; gif: Gif; }) { const [name, setName] = useState(""); - const onSubmit = useCallback((e: React.FormEvent) => { - e.preventDefault(); + const onSubmit = useCallback((e?: React.FormEvent) => { + e?.preventDefault(); if (!name.length) return; createCollection(name, [gif]); props.onClose(); }, [name, gif, props]); return ( - +
- - Create Collection - - - Collection Name - - - - - + Collection Name + -
+ ); } -function RenameCollectionModal({ props, name }: { props: ModalProps; name: string; }) { +function RenameCollectionModal({ props, name }: { props: RenderModalProps; name: string; }) { const prefix = settings.store.collectionPrefix; const strippedName = name.startsWith(prefix) ? name.slice(prefix.length) : name; const [newName, setNewName] = useState(strippedName); const tooLong = newName.length >= 25; - const onSubmit = useCallback(async (e: React.FormEvent) => { - e.preventDefault(); + const onSubmit = useCallback(async (e?: React.FormEvent) => { + e?.preventDefault(); if (!newName.length || tooLong) return; await renameCollection(name, newName); props.onClose(); }, [newName, name, tooLong, props]); return ( - +
- - Rename Collection - - - New Collection Name - - {tooLong && Name can't be longer than 24 characters} - - - - + New Collection Name + + {tooLong && Name can't be longer than 24 characters} -
+ ); } diff --git a/src/equicordplugins/githubRepos/components/ProfilePopoutComponent.tsx b/src/equicordplugins/githubRepos/components/ProfilePopoutComponent.tsx index 617ac8d3d..88591a36d 100644 --- a/src/equicordplugins/githubRepos/components/ProfilePopoutComponent.tsx +++ b/src/equicordplugins/githubRepos/components/ProfilePopoutComponent.tsx @@ -9,9 +9,8 @@ import { Span } from "@components/Span"; import { fetchReposByUserId, fetchReposByUsername, fetchUserInfo, GitHubUserInfo } from "@equicordplugins/githubRepos/githubApi"; import { GitHubRepo } from "@equicordplugins/githubRepos/types"; import { classes } from "@utils/misc"; -import { openModal } from "@utils/modal"; import { findCssClassesLazy } from "@webpack"; -import { Clickable, React, useEffect, UserProfileStore, useState } from "@webpack/common"; +import { Clickable, openModal,React, useEffect, UserProfileStore, useState } from "@webpack/common"; import { ReposModal } from "./ReposModal"; diff --git a/src/equicordplugins/githubRepos/components/ProfileTabComponent.tsx b/src/equicordplugins/githubRepos/components/ProfileTabComponent.tsx index 3008f94a0..8b79bbcdd 100644 --- a/src/equicordplugins/githubRepos/components/ProfileTabComponent.tsx +++ b/src/equicordplugins/githubRepos/components/ProfileTabComponent.tsx @@ -7,8 +7,7 @@ import { BaseText } from "@components/BaseText"; import { fetchReposByUserId, fetchReposByUsername, fetchUserInfo, GitHubUserInfo } from "@equicordplugins/githubRepos/githubApi"; import { GitHubRepo } from "@equicordplugins/githubRepos/types"; -import { openModal } from "@utils/modal"; -import { React, useEffect, UserProfileStore, useState } from "@webpack/common"; +import { openModal,React, useEffect, UserProfileStore, useState } from "@webpack/common"; import { cl, settings } from ".."; import { RepoCard } from "./RepoCard"; diff --git a/src/equicordplugins/githubRepos/components/ReposModal.tsx b/src/equicordplugins/githubRepos/components/ReposModal.tsx index 36bcc0902..885c9a643 100644 --- a/src/equicordplugins/githubRepos/components/ReposModal.tsx +++ b/src/equicordplugins/githubRepos/components/ReposModal.tsx @@ -4,12 +4,10 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { Button } from "@components/Button"; -import { HeadingPrimary } from "@components/Heading"; import { getLanguageColor } from "@equicordplugins/githubRepos/colors"; import { GitHubRepo } from "@equicordplugins/githubRepos/types"; -import { ModalContent, ModalFooter, ModalHeader, ModalRoot } from "@utils/modal"; -import { React } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal, React } from "@webpack/common"; import { cl } from ".."; import { Star } from "./Star"; @@ -20,7 +18,7 @@ interface ReposModalProps { rootProps: any; } -export function ReposModal({ repos, username, rootProps }: ReposModalProps) { +export function ReposModal({ repos, username, rootProps }: ReposModalProps & { rootProps: RenderModalProps; }) { const renderTableHeader = () => ( @@ -63,44 +61,38 @@ export function ReposModal({ repos, username, rootProps }: ReposModalProps) { ); return ( - - - - {username}'s GitHub Repositories - - - -
- - - - - - - - {renderTableHeader()} - - {repos.map(renderTableRow)} - -
-
-
- - - - -
+ window.open(`https://github.com/${username}?tab=repositories`, "_blank") + }, + { + text: "Close", + variant: "secondary", + onClick: rootProps.onClose + } + ]} + > +
+ + + + + + + + {renderTableHeader()} + + {repos.map(renderTableRow)} + +
+
+
); } diff --git a/src/equicordplugins/globalBadges/badgeModal.tsx b/src/equicordplugins/globalBadges/badgeModal.tsx index e2c501b41..98a91ebec 100644 --- a/src/equicordplugins/globalBadges/badgeModal.tsx +++ b/src/equicordplugins/globalBadges/badgeModal.tsx @@ -4,14 +4,12 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { Button } from "@components/Button"; import ErrorBoundary from "@components/ErrorBoundary"; import { HeadingTertiary } from "@components/Heading"; import { Paragraph } from "@components/Paragraph"; import { openInviteModal } from "@utils/discord"; -import { ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal"; -import { User } from "@vencord/discord-types"; -import { React, Tooltip } from "@webpack/common"; +import { RenderModalProps, User } from "@vencord/discord-types"; +import { Modal, openModal, React, Tooltip } from "@webpack/common"; import { cl, GlobalBadges, INVITE_LINK } from "./utils"; @@ -37,20 +35,32 @@ export function openBadgeModal(user: User) { )); - openModal(modalprops => ( - - - + openModal((modalprops: RenderModalProps) => ( + - + {user.username} - - +
+ } + actions={[ + { + text: "Join GlobalBadges Server", + variant: "link", + onClick: () => openInviteModal(INVITE_LINK) + } + ]} + > + +
{badgeDataElements.length ? ( <> @@ -66,16 +76,8 @@ export function openBadgeModal(user: User) { No global badges. )} - - - - +
- +
)); } diff --git a/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx b/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx index cdf840d10..863a6b848 100644 --- a/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx +++ b/src/equicordplugins/hideServers/components/HiddenServersMenu.tsx @@ -10,40 +10,21 @@ import { HiddenServersStore } from "@equicordplugins/hideServers/HiddenServersSt import { classNameFactory } from "@utils/css"; import { getGuildAcronym } from "@utils/discord"; import { classes } from "@utils/misc"; -import { - closeModal, - ModalCloseButton, - ModalContent, - ModalHeader, - ModalProps, - ModalRoot, - ModalSize, - openModal, -} from "@utils/modal"; -import { Guild } from "@vencord/discord-types"; +import { Guild, RenderModalProps } from "@vencord/discord-types"; import { findCssClassesLazy } from "@webpack"; -import { Button, IconUtils, useStateFromStores } from "@webpack/common"; +import { Button, closeModal, IconUtils, Modal,openModal, useStateFromStores } from "@webpack/common"; import { SortedGuildStore } from ".."; const cl = classNameFactory("vc-hideservers-"); const IconClasses = findCssClassesLazy("icon", "acronym", "childWrapper"); -function HiddenServersModal({ modalProps, close }: { modalProps: ModalProps; close(): void; }) { +function HiddenServersModal({ modalProps, close }: { modalProps: RenderModalProps; close(): void; }) { const guilds = useStateFromStores([HiddenServersStore], () => HiddenServersStore.hiddenGuildsDetail()); return ( - - - - Hidden Servers - - - - - - - - + + + ); } diff --git a/src/equicordplugins/iconViewer/components/Modals.tsx b/src/equicordplugins/iconViewer/components/Modals.tsx index 67cc8e8fb..7dfa433fb 100644 --- a/src/equicordplugins/iconViewer/components/Modals.tsx +++ b/src/equicordplugins/iconViewer/components/Modals.tsx @@ -5,7 +5,6 @@ */ import { BaseText } from "@components/BaseText"; -import { Button } from "@components/Button"; import { CodeBlock } from "@components/CodeBlock"; import { Flex } from "@components/Flex"; import { HeadingSecondary } from "@components/Heading"; @@ -13,18 +12,8 @@ import { Paragraph } from "@components/Paragraph"; import { TooltipContainer } from "@components/TooltipContainer"; import { copyWithToast, getIntlMessage } from "@utils/discord"; import { Logger } from "@utils/Logger"; -import { - CloseButton, - ModalContent, - ModalFooter, - ModalHeader, - ModalProps, - ModalRoot, - ModalSize, - openModal -} from "@utils/modal"; import { saveFile } from "@utils/web"; -import { Icon } from "@vencord/discord-types"; +import { Icon, RenderModalProps } from "@vencord/discord-types"; import { findComponentByCodeLazy } from "@webpack"; import { Clickable, @@ -32,6 +21,8 @@ import { createRoot, FluxDispatcher, Menu, + Modal, + openModal, ReactDOM, useCallback, useEffect, @@ -226,7 +217,7 @@ function OtherContextMenu({ iconName, Icon, color }: { iconName: string; Icon: I ); } -function IconModal({ iconName, Icon, onClose, transitionState }: { iconName: string; Icon: Icon; } & ModalProps) { +function IconModal({ iconName, Icon, onClose, transitionState }: { iconName: string; Icon: Icon; } & RenderModalProps) { const [color, setColor] = useColorNavigation(209); const colorData = cssColors[color]; const colorKeys = useMemo(() => getCssColorKeys(), []); @@ -247,62 +238,59 @@ function IconModal({ iconName, Icon, onClose, transitionState }: { iconName: str }); }, [colorKeys.length, setColor]); - const openOtherMenu = (e: React.MouseEvent) => { - ContextMenuApi.openContextMenu(e, () => ( + const openOtherMenu = (e?: React.MouseEvent) => { + if (e) ContextMenuApi.openContextMenu(e, () => ( )); }; return ( - - -
- {iconName} + + +
+
-
- -
- - - -
- -
- - - {iconSizes.map(size => ( - - - - ))} - - - - {colorData?.name} - - + + + {iconSizes.map(size => ( + + + + ))} + + + {colorData?.name} + + -
- Usage - Click to copy -
- {/* for some reason i cant make this shit codeblock full width, FF 15 */} - copyWithToast(findCode, "Copied!")}> - - -
- - - - +
+
+ Usage + Click to copy +
+ {/* for some reason i cant make this shit codeblock full width, FF 15 */} + copyWithToast(findCode, "Copied!")}> + + +
); } diff --git a/src/equicordplugins/inRole/RoleMembersModal.tsx b/src/equicordplugins/inRole/RoleMembersModal.tsx index 6483b105b..c628f985d 100644 --- a/src/equicordplugins/inRole/RoleMembersModal.tsx +++ b/src/equicordplugins/inRole/RoleMembersModal.tsx @@ -7,38 +7,35 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Paragraph } from "@components/Paragraph"; import { classNameFactory } from "@utils/css"; -import { ModalCloseButton, ModalContent, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { GuildMember } from "@vencord/discord-types"; -import { Parser } from "@webpack/common"; +import { GuildMember, RenderModalProps } from "@vencord/discord-types"; +import { Modal,openModal, Parser, React } from "@webpack/common"; const cl = classNameFactory("vc-inrole-"); export function showInRoleModal(members: GuildMember[], roleId: string, channelId: string) { - openModal(props => - <> - - - - Members of role { - Parser.parse(`<@&${roleId}>`, true, { channelId, viewingChannelId: channelId }) - } ({members.length}) - - - -
- { - members.length !== 0 ? members.map(member => - <> - - {Parser.parse(`<@${member.userId}>`, true, { channelId, viewingChannelId: channelId })} - - - ) : Looks like no online cached members with that role were found. Try scrolling down on your member list to cache more users! - } -
-
-
-
- + openModal((props: RenderModalProps) => + + + Members of role {Parser.parse(`<@&${roleId}>`, true, { channelId, viewingChannelId: channelId })} ({members.length}) + + } + > +
+ { + members.length !== 0 ? members.map(member => + + + {Parser.parse(`<@${member.userId}>`, true, { channelId, viewingChannelId: channelId })} + + + ) : Looks like no online cached members with that role were found. Try scrolling down on your member list to cache more users! + } +
+
+
); } diff --git a/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx b/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx index b4946e28f..542d88230 100644 --- a/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx +++ b/src/equicordplugins/invisibleChat.desktop/components/DecryptionModal.tsx @@ -16,59 +16,49 @@ * along with this program. If not, see . */ -import { Heading, HeadingTertiary } from "@components/Heading"; -import { - ModalContent, - ModalFooter, - ModalHeader, - ModalRoot, - openModal, -} from "@utils/modal"; -import { Button, React, TextInput } from "@webpack/common"; +import { Heading } from "@components/Heading"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal, openModal, React, TextInput } from "@webpack/common"; import { buildEmbed, decrypt } from "../index"; -export function DecModal(props: any) { +export function DecModal(props: RenderModalProps & { message: any; }) { const encryptedMessage: string = props?.message?.content; const [password, setPassword] = React.useState("password"); + const onDecrypt = () => { + const toSend = decrypt(encryptedMessage, password, true); + if (!toSend || !props?.message) return; + buildEmbed(props?.message, toSend); + props.onClose(); + }; + return ( - - - Decrypt Message - - - - Message with Encryption - - Password - - - - - - - - + + Message with Encryption + + Password + + ); } diff --git a/src/equicordplugins/invisibleChat.desktop/components/EncryptionModal.tsx b/src/equicordplugins/invisibleChat.desktop/components/EncryptionModal.tsx index 04a225d5c..f27f11f82 100644 --- a/src/equicordplugins/invisibleChat.desktop/components/EncryptionModal.tsx +++ b/src/equicordplugins/invisibleChat.desktop/components/EncryptionModal.tsx @@ -17,21 +17,14 @@ */ import { FormSwitch } from "@components/FormSwitch"; -import { Heading, HeadingTertiary } from "@components/Heading"; +import { Heading } from "@components/Heading"; import { insertTextIntoChatInputBox } from "@utils/discord"; -import { - ModalContent, - ModalFooter, - ModalHeader, - ModalProps, - ModalRoot, - openModal, -} from "@utils/modal"; -import { Button, React, TextInput } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal, openModal, React, TextInput } from "@webpack/common"; import { encrypt } from "../index"; -function EncModal(props: ModalProps) { +function EncModal(props: RenderModalProps) { const [secret, setSecret] = React.useState(""); const [cover, setCover] = React.useState(""); const [password, setPassword] = React.useState("password"); @@ -39,72 +32,65 @@ function EncModal(props: ModalProps) { const isValid = secret && (noCover || (cover && cover.trim().split(" ").length > 1)); + const onSend = () => { + if (!isValid) return; + const encrypted = encrypt(secret, password, noCover ? "d d" : cover); + const toSend = noCover ? encrypted.replaceAll("d", "") : encrypted; + if (!toSend) return; + + insertTextIntoChatInputBox(toSend); + + props.onClose(); + }; + return ( - - - Encrypt Message - - - - Secret - { - setSecret(e); - }} - /> - Cover (2 or more Words!!) - { - setCover(e); - }} - /> - Password - { - setPassword(e); - }} - /> - { - setNoCover(e); - }} - /> - - - - - - - + + Secret + { + setSecret(e); + }} + /> + Cover (2 or more Words!!) + { + setCover(e); + }} + /> + Password + { + setPassword(e); + }} + /> + { + setNoCover(e); + }} + /> + ); } diff --git a/src/equicordplugins/keyboardNavigation/components/CommandPalette.tsx b/src/equicordplugins/keyboardNavigation/components/CommandPalette.tsx index d860aeace..5ea75ed67 100644 --- a/src/equicordplugins/keyboardNavigation/components/CommandPalette.tsx +++ b/src/equicordplugins/keyboardNavigation/components/CommandPalette.tsx @@ -9,14 +9,14 @@ import "./style.css"; import { actions } from "@equicordplugins/keyboardNavigation/commands"; import { classNameFactory } from "@utils/css"; import { Logger } from "@utils/Logger"; -import { closeAllModals, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { React, TextInput, useEffect, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { closeAllModals, Modal,openModal, React, TextInput, useEffect, useState } from "@webpack/common"; import { settings } from ".."; const logger = new Logger("CommandPalette", "#e5c890"); -export function CommandPalette({ modalProps }) { +export function CommandPalette({ modalProps }: { modalProps: RenderModalProps; }) { const cl = classNameFactory("vc-command-palette-"); const [focusedIndex, setFocusedIndex] = useState(null); const [startIndex, setStartIndex] = useState(0); @@ -100,8 +100,8 @@ export function CommandPalette({ modalProps }) { }, [queryEh]); return ( - -
+ +
setQuery(e)} @@ -123,7 +123,7 @@ export function CommandPalette({ modalProps }) { ))}
-
+ ); } diff --git a/src/equicordplugins/keyboardNavigation/components/MultipleChoice.tsx b/src/equicordplugins/keyboardNavigation/components/MultipleChoice.tsx index 2929f1a94..b8a0a48fa 100644 --- a/src/equicordplugins/keyboardNavigation/components/MultipleChoice.tsx +++ b/src/equicordplugins/keyboardNavigation/components/MultipleChoice.tsx @@ -8,13 +8,13 @@ import "./style.css"; import { ButtonAction } from "@equicordplugins/keyboardNavigation/commands"; import { classNameFactory } from "@utils/css"; -import { closeAllModals, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { React, TextInput, useEffect, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { closeAllModals, Modal,openModal, React, TextInput, useEffect, useState } from "@webpack/common"; import { settings } from ".."; interface MultipleChoiceProps { - modalProps: ModalProps; + modalProps: RenderModalProps; onSelect: (selectedValue: any) => void; choices: ButtonAction[]; } @@ -99,9 +99,8 @@ export function MultipleChoice({ modalProps, onSelect, choices }: MultipleChoice }, [queryEh]); return ( - // @ts-ignore - -
+ +
setQuery(e)} @@ -123,7 +122,7 @@ export function MultipleChoice({ modalProps, onSelect, choices }: MultipleChoice ))}
-
+ ); } diff --git a/src/equicordplugins/keyboardNavigation/components/TextInput.tsx b/src/equicordplugins/keyboardNavigation/components/TextInput.tsx index a070137ac..3198ce4b6 100644 --- a/src/equicordplugins/keyboardNavigation/components/TextInput.tsx +++ b/src/equicordplugins/keyboardNavigation/components/TextInput.tsx @@ -6,11 +6,11 @@ import "./style.css"; -import { closeAllModals, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { React, TextInput, useEffect, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { closeAllModals, Modal,openModal, React, TextInput, useEffect, useState } from "@webpack/common"; interface SimpleTextInputProps { - modalProps: ModalProps; + modalProps: RenderModalProps; onSelect: (inputValue: string) => void; placeholder?: string; info?: string; @@ -35,16 +35,17 @@ export function SimpleTextInput({ modalProps, onSelect, placeholder, info }: Sim }, []); return ( - // @ts-ignore - - setInputValue(e as unknown as string)} - style={{ width: "30vw", borderRadius: "5px" }} - placeholder={placeholder ?? "Type and press Enter"} - /> - {info &&
{info}
} -
+ +
+ setInputValue(e as unknown as string)} + style={{ width: "30vw", borderRadius: "5px" }} + placeholder={placeholder ?? "Type and press Enter"} + /> + {info &&
{info}
} +
+
); } diff --git a/src/equicordplugins/keyboardNavigation/index.tsx b/src/equicordplugins/keyboardNavigation/index.tsx index 852edafa6..2f10bee4f 100644 --- a/src/equicordplugins/keyboardNavigation/index.tsx +++ b/src/equicordplugins/keyboardNavigation/index.tsx @@ -7,9 +7,8 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; import { classNameFactory } from "@utils/css"; -import { closeAllModals } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; -import { SettingsRouter, useState } from "@webpack/common"; +import { closeAllModals,SettingsRouter, useState } from "@webpack/common"; import { registerAction } from "./commands"; import { openCommandPalette } from "./components/CommandPalette"; diff --git a/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx b/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx index 302640d56..f6da905fa 100644 --- a/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx +++ b/src/equicordplugins/loginWithQR/ui/modals/QrModal.tsx @@ -9,9 +9,6 @@ import { QrCodeIcon } from "@components/Icons"; import { wrapTab } from "@components/settings"; import loginWithQR from "@equicordplugins/loginWithQR"; import { images } from "@equicordplugins/loginWithQR/images"; -import { - ModalProps, -} from "@utils/modal"; import { findByPropsLazy } from "@webpack"; import { RestAPI, @@ -135,7 +132,7 @@ const handleProcessImage = (file: File, modalPropsRef: QrModalPropsRef) => { reader.readAsDataURL(file); }; -function QrModal(props: ModalProps) { +function QrModal() { const [state, setState] = useState(LoginStateType.Idle); const [preview, setPreview] = useState(null); const error = useRef(null); diff --git a/src/equicordplugins/loginWithQR/ui/modals/VerifyModal.tsx b/src/equicordplugins/loginWithQR/ui/modals/VerifyModal.tsx index f988367a5..5c239be74 100644 --- a/src/equicordplugins/loginWithQR/ui/modals/VerifyModal.tsx +++ b/src/equicordplugins/loginWithQR/ui/modals/VerifyModal.tsx @@ -8,21 +8,15 @@ import { BaseText } from "@components/BaseText"; import { Button, TextButton } from "@components/Button"; import { images } from "@equicordplugins/loginWithQR/images"; import { getIntlMessage } from "@utils/discord"; -import { - ModalContent, - ModalFooter, - ModalProps, - ModalRoot, - ModalSize, - openModal, -} from "@utils/modal"; +import { RenderModalProps } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; import { + Modal, + openModal, RestAPI, useEffect, useRef, - useState, -} from "@webpack/common"; + useState } from "@webpack/common"; import { cl } from ".."; @@ -41,7 +35,7 @@ function VerifyModal({ }: { token: string | null; onAbort: () => void; -} & ModalProps) { +} & RenderModalProps) { const [state, setState] = useState( !token ? VerifyState.NotFound : VerifyState.Verifying ); @@ -112,8 +106,8 @@ function VerifyModal({ }, [state]); return ( - - + +
{state === VerifyState.LoggedIn ? ( <> )} - - +
+
{state === VerifyState.LoggedIn ? (
+
); } diff --git a/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx b/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx index 3fa47d67b..20a961ca8 100644 --- a/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx +++ b/src/equicordplugins/messageLoggerEnhanced/components/LogsModal.tsx @@ -8,13 +8,11 @@ import { BaseText } from "@components/BaseText"; import { Button } from "@components/Button"; import { Flex } from "@components/Flex"; import { InfoIcon } from "@components/Icons"; -import { Link } from "@components/Link"; import { copyWithToast, openUserProfile } from "@utils/discord"; -import { closeAllModals, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { LazyComponent } from "@utils/react"; -import { type User } from "@vencord/discord-types"; +import { RenderModalProps, type User } from "@vencord/discord-types"; import { find, findByCode, findByCodeLazy } from "@webpack"; -import { Alerts, ChannelStore, ContextMenuApi, FluxDispatcher, GuildStore, Menu, NavigationRouter, React, TabBar, TextInput, Tooltip, useMemo, useRef, useState } from "@webpack/common"; +import { Alerts, ChannelStore, closeAllModals, ContextMenuApi, FluxDispatcher, GuildStore, Menu, Modal, NavigationRouter, openModal, React, TabBar, TextInput, Tooltip, useMemo, useRef, useState } from "@webpack/common"; import { DBMessageRecord, deleteMessageIDB, deleteMessagesBulkIDB } from "../db"; import { cl, clearLogs, settings } from "../index"; @@ -62,7 +60,7 @@ export enum LogTabs { } interface Props { - modalProps: ModalProps; + modalProps: RenderModalProps; initalQuery?: string; } @@ -76,46 +74,96 @@ export function LogsModal({ modalProps, initalQuery }: Props) { const { messages, total, statusTotal, pending, reset } = useMessages(queryEh, currentTab, sortNewest, numDisplayedMessages); return ( - - - setQuery(e)} style={{ width: "100%" }} placeholder="Filter Messages" /> - { - setCurrentTab(e); - setNumDisplayedMessages(settings.store.messagesToDisplayAtOnceInLogs); + + setQuery(e)} style={{ width: "100%" }} placeholder="Filter Messages" /> + { + setCurrentTab(e); + setNumDisplayedMessages(settings.store.messagesToDisplayAtOnceInLogs); + contentRef.current?.firstElementChild?.scrollTo(0, 0); + }} + > + + Deleted + + + Edited + + + Ghost Pinged + + +
+ } + actions={[ + { + text: "Clear All Logs", + variant: "dangerPrimary", + onClick: () => Alerts.show({ + title: "Clear Logs", + body: "Are you sure you want to clear all the logs", + confirmText: "Clear", + // @ts-expect-error not typed + confirmVariant: "critical-primary", + cancelText: "Cancel", + onConfirm: async () => { + await clearLogs(); + reset(); + } + }) + }, + { + text: "Clear Visible Logs", + variant: "dangerSecondary", + disabled: messages?.length === 0, + onClick: () => Alerts.show({ + title: "Clear Logs", + body: `Are you sure you want to clear ${messages.length} logs`, + confirmText: "Clear", + // @ts-expect-error not typed + confirmVariant: "critical-primary", + cancelText: "Cancel", + onConfirm: async () => { + await deleteMessagesBulkIDB(messages.map(e => e.message_id)); + reset(); + } + }) + }, + { + text: `Sort ${sortNewest ? "Oldest First" : "Newest First"}`, + variant: "secondary", + onClick: () => { + setSortNewest(e => { + const val = !e; + settings.store.sortNewest = val; + return val; + }); contentRef.current?.firstElementChild?.scrollTo(0, 0); - }} - > - - Deleted - - - Edited - - - Ghost Pinged - - -
-
+ } + } + ]} + > +
{ modalProps.transitionState === 1 && - +
{messages != null && total === 0 && ( setNumDisplayedMessages(e => e + settings.store.messagesToDisplayAtOnceInLogs)} /> )} - +
}
- - - - { - setSortNewest(e => { - const val = !e; - settings.store.sortNewest = val; - return val; - }); - contentRef.current?.firstElementChild?.scrollTo(0, 0); - }} - > - Sort {sortNewest ? "Oldest First" : "Newest First"} - - - + ); } diff --git a/src/equicordplugins/moreStickers/components/picker.tsx b/src/equicordplugins/moreStickers/components/picker.tsx index 6c652a3c8..c8e373584 100644 --- a/src/equicordplugins/moreStickers/components/picker.tsx +++ b/src/equicordplugins/moreStickers/components/picker.tsx @@ -4,13 +4,11 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { HeadingPrimary } from "@components/Heading"; import { PickerContent, PickerContentHeader, PickerContentRow, PickerContentRowGrid, PickerHeaderProps, SidebarProps, Sticker, StickerCategoryType, StickerPack } from "@equicordplugins/moreStickers/types"; import { sendSticker } from "@equicordplugins/moreStickers/upload"; import { clPicker, FFmpegStateContext } from "@equicordplugins/moreStickers/utils"; import { debounce } from "@shared/debounce"; -import { ModalContent, ModalHeader, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { React, TextInput } from "@webpack/common"; +import { Modal,openModal, React, TextInput } from "@webpack/common"; import { JSX } from "react"; import { CategoryImage, CategoryScroller, CategoryWrapper, StickerCategory } from "./categories"; @@ -72,14 +70,9 @@ export const PickerSidebar = ({ packMetas, onPackSelect }: SidebarProps) => { onClick={() => { openModal(modalProps => { return ( - - - Stickers+ - - - - - + + + ); }); }} diff --git a/src/equicordplugins/musicControls/spotify/lyrics/components/lyrics.tsx b/src/equicordplugins/musicControls/spotify/lyrics/components/lyrics.tsx index c4b15fa64..d028ded7f 100644 --- a/src/equicordplugins/musicControls/spotify/lyrics/components/lyrics.tsx +++ b/src/equicordplugins/musicControls/spotify/lyrics/components/lyrics.tsx @@ -9,8 +9,7 @@ import { TooltipContainer } from "@components/TooltipContainer"; import { settings } from "@equicordplugins/musicControls/settings"; import { SpotifyLrcStore } from "@equicordplugins/musicControls/spotify/lyrics/providers/store"; import { SpotifyStore } from "@equicordplugins/musicControls/spotify/SpotifyStore"; -import { openModal } from "@utils/modal"; -import { ContextMenuApi, React, useEffect, useState, useStateFromStores } from "@webpack/common"; +import { ContextMenuApi, openModal,React, useEffect, useState, useStateFromStores } from "@webpack/common"; import { LyricsContextMenu } from "./ctxMenu"; import { LyricsModal } from "./modal"; diff --git a/src/equicordplugins/musicControls/spotify/lyrics/components/modal.tsx b/src/equicordplugins/musicControls/spotify/lyrics/components/modal.tsx index 71141e9a8..ef39de086 100644 --- a/src/equicordplugins/musicControls/spotify/lyrics/components/modal.tsx +++ b/src/equicordplugins/musicControls/spotify/lyrics/components/modal.tsx @@ -7,8 +7,8 @@ import { BaseText } from "@components/BaseText"; import { SpotifyStore, Track } from "@equicordplugins/musicControls/spotify/SpotifyStore"; import { openImageModal } from "@utils/discord"; -import { ModalContent, ModalHeader, ModalProps, ModalRoot } from "@utils/modal"; -import { React } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal,React } from "@webpack/common"; import { cl, NoteSvg, scrollClasses, useLyrics } from "./util"; @@ -18,72 +18,63 @@ const formatTime = (time: number) => { return `${minutes}:${seconds.toString().padStart(2, "0")}`; }; -function ModalHeaderContent({ track }: { track: Track | null; }) { +function getTitleNode(track: Track | null) { if (!track) { - return ( - - No track playing - - ); + return No track playing; } return ( - -
- {track?.album?.image?.url && ( - {track.album.name} openImageModal({ - url: track.album.image.url, - width: track.album.image.width, - height: track.album.image.height, - })} - /> - )} -
- {track.name} - by {track.artists.map(a => a.name).join(", ")} - on {track.album.name} -
+
+ {track?.album?.image?.url && ( + {track.album.name} openImageModal({ + url: track.album.image.url, + width: track.album.image.width, + height: track.album.image.height, + })} + /> + )} +
+ {track.name} + by {track.artists.map(a => a.name).join(", ")} + on {track.album.name}
- +
); } const modalCurrentLine = cl("modal-line-current"); const modalLine = cl("modal-line"); -export function LyricsModal({ props }: { props: ModalProps; }) { +export function LyricsModal({ props }: { props: RenderModalProps; }) { const { track, lyricsInfo, currLrcIndex } = useLyrics({ scroll: false }); const currentLyrics = lyricsInfo?.lyricsVersions[lyricsInfo.useLyric]; return ( - - - -
- {currentLyrics ? ( - currentLyrics.map((line, i) => ( - - SpotifyStore.seek(line.time * 1000)}> - {formatTime(line.time)} - - {line.text || NoteSvg()} - - )) - ) : ( - - No lyrics available :( + +
+ {currentLyrics ? ( + currentLyrics.map((line, i) => ( + + SpotifyStore.seek(line.time * 1000)}> + {formatTime(line.time)} + + {line.text || NoteSvg()} - )} -
- - + )) + ) : ( + + No lyrics available :( + + )} +
+ ); } diff --git a/src/equicordplugins/musicControls/tidal/lyrics/components/lyrics.tsx b/src/equicordplugins/musicControls/tidal/lyrics/components/lyrics.tsx index 702393a4f..772d4c427 100644 --- a/src/equicordplugins/musicControls/tidal/lyrics/components/lyrics.tsx +++ b/src/equicordplugins/musicControls/tidal/lyrics/components/lyrics.tsx @@ -9,8 +9,7 @@ import { TooltipContainer } from "@components/TooltipContainer"; import { settings } from "@equicordplugins/musicControls/settings"; import { TidalLrcStore } from "@equicordplugins/musicControls/tidal/lyrics/providers/store"; import { TidalStore } from "@equicordplugins/musicControls/tidal/TidalStore"; -import { openModal } from "@utils/modal"; -import { ContextMenuApi, useEffect, useState, useStateFromStores } from "@webpack/common"; +import { ContextMenuApi, openModal,useEffect, useState, useStateFromStores } from "@webpack/common"; import { LyricsContextMenu } from "./ctxMenu"; import { LyricsModal } from "./modal"; diff --git a/src/equicordplugins/musicControls/tidal/lyrics/components/modal.tsx b/src/equicordplugins/musicControls/tidal/lyrics/components/modal.tsx index c5337e5c4..8aa6a6aa2 100644 --- a/src/equicordplugins/musicControls/tidal/lyrics/components/modal.tsx +++ b/src/equicordplugins/musicControls/tidal/lyrics/components/modal.tsx @@ -6,7 +6,8 @@ import { BaseText } from "@components/BaseText"; import { TidalStore, Track } from "@equicordplugins/musicControls/tidal/TidalStore"; -import { ModalContent, ModalHeader, ModalProps, ModalRoot } from "@utils/modal"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal,React } from "@webpack/common"; import { cl, NoteSvg, scrollClasses, useLyrics } from "./util"; @@ -16,58 +17,54 @@ const formatTime = (time: number) => { return `${minutes}:${seconds.toString().padStart(2, "0")}`; }; -function ModalHeaderContent({ track }: { track: Track; }) { +function getTitleNode(track: Track | null) { + if (!track) return null; return ( - -
- {track?.imageSrc && ( - {track.album - )} -
- {track.name} - by {track.artist} - {track.album && on {track.album}} -
+
+ {track?.imageSrc && ( + {track.album + )} +
+ {track.name} + by {track.artist} + {track.album && on {track.album}}
- +
); } -export function LyricsModal({ rootProps }: { rootProps: ModalProps; }) { +export function LyricsModal({ rootProps }: { rootProps: RenderModalProps; }) { const { track, lyrics, currLrcIndex } = useLyrics({ scroll: false }); const currentLyrics = lyrics || null; const position = track ? TidalStore.mPosition : 0; return ( - - {track && } - -
- {currentLyrics ? ( - currentLyrics.map((line, i) => ( - +
+ {currentLyrics ? ( + currentLyrics.map((line, i) => ( + + TidalStore.seek(line.time * 1000)} > - TidalStore.seek(line.time * 1000)} - > - {formatTime(line.time)} - - {line.text || NoteSvg(cl("modal-note"))} - - )) - ) : ( - No lyrics available :( - )} -
- - + {formatTime(line.time)} + + {line.text || NoteSvg(cl("modal-note"))} +
+ )) + ) : ( + No lyrics available :( + )} +
+ ); } diff --git a/src/equicordplugins/newPluginsManager/NewPluginsModal.tsx b/src/equicordplugins/newPluginsManager/NewPluginsModal.tsx index 22f683a06..5be532abb 100644 --- a/src/equicordplugins/newPluginsManager/NewPluginsModal.tsx +++ b/src/equicordplugins/newPluginsManager/NewPluginsModal.tsx @@ -10,15 +10,14 @@ import { Settings, useSettings } from "@api/Settings"; import { BaseText } from "@components/BaseText"; import { Button } from "@components/Button"; import ErrorBoundary from "@components/ErrorBoundary"; -import { Flex } from "@components/Flex"; import { PluginDependencyList } from "@components/settings/tabs/plugins"; import { PluginCard } from "@components/settings/tabs/plugins/PluginCard"; import { ChangeList } from "@utils/ChangeList"; import { classNameFactory } from "@utils/css"; -import { CloseButton, closeModal, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import { useForceUpdater } from "@utils/react"; +import { RenderModalProps } from "@vencord/discord-types"; import { findComponentByCodeLazy } from "@webpack"; -import { Tooltip, useMemo } from "@webpack/common"; +import { closeModal, Modal,openModal, Tooltip, useMemo } from "@webpack/common"; import { ReactNode } from "react"; import Plugins from "~plugins"; @@ -32,7 +31,7 @@ const Checkbox = findComponentByCodeLazy('"data-toggleable-component":"checkbox' let hasSeen = false; interface ModalComponentProps { - modalProps: ModalProps; + modalProps: RenderModalProps; newPlugins: Set; newSettings: KnownPluginSettingsMap; } @@ -121,8 +120,10 @@ function NewPluginsModal({ modalProps, newPlugins, newSettings }: ModalComponent }; return ( - - + New Plugins and Settings ({totalCount}) @@ -131,53 +132,46 @@ function NewPluginsModal({ modalProps, newPlugins, newSettings }: ModalComponent New plugins have been added since your last visit. Enable any you'd like or continue to dismiss.
-
- -
-
+ } + > +
+ {pluginCards} + {requiredPluginCards} +
- -
- {pluginCards} - {requiredPluginCards} -
-
+
+ + The following plugins require a restart: +
    + {changes.map(p =>
  • {p}
  • )} +
+ + } + shouldShow={changes.hasChanges} + > + {tooltipProps => ( + + )} +
- - - - The following plugins require a restart: -
    - {changes.map(p =>
  • {p}
  • )} -
- - } - shouldShow={changes.hasChanges} - > - {tooltipProps => ( - - )} -
- - { - Settings.plugins.NewPluginsManager.enabled = !settings?.plugins?.NewPluginsManager?.enabled; - }} - > - Don't show this again - -
-
- + { + Settings.plugins.NewPluginsManager.enabled = !settings?.plugins?.NewPluginsManager?.enabled; + }} + > + Don't show this again + +
+ ); } diff --git a/src/equicordplugins/profileSets/components/confirmModal.tsx b/src/equicordplugins/profileSets/components/confirmModal.tsx index 76da537d0..2d507b138 100644 --- a/src/equicordplugins/profileSets/components/confirmModal.tsx +++ b/src/equicordplugins/profileSets/components/confirmModal.tsx @@ -4,11 +4,11 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { Button } from "@components/Button"; -import { Heading } from "@components/Heading"; import { Paragraph } from "@components/Paragraph"; -import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot } from "@utils/modal"; -interface ConfirmModalProps extends ModalProps { +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal, React } from "@webpack/common"; + +interface ConfirmModalProps extends RenderModalProps { title: string; message: string; confirmText: string; @@ -17,7 +17,7 @@ interface ConfirmModalProps extends ModalProps { onCancel: () => void; } -interface ImportProfilesModalProps extends ModalProps { +interface ImportProfilesModalProps extends RenderModalProps { title: string; message: string; onOverride: () => void; @@ -25,57 +25,65 @@ interface ImportProfilesModalProps extends ModalProps { onCancel: () => void; } -export function ConfirmModal({ title, message, confirmText, cancelText, onConfirm, onCancel, onClose, transitionState }: ConfirmModalProps) { +export function ConfirmModal({ title, message, confirmText, cancelText, onConfirm, onCancel, ...props }: ConfirmModalProps) { const closeAfter = (action: () => void) => () => { action(); - onClose(); + props.onClose(); }; return ( - - - {title} - - - {message} - - - - - - + + {message} + ); } -export function ImportProfilesModal({ title, message, onOverride, onMerge, onCancel, onClose, transitionState }: ImportProfilesModalProps) { +export function ImportProfilesModal({ title, message, onOverride, onMerge, onCancel, ...props }: ImportProfilesModalProps) { const closeAfter = (action: () => void) => () => { action(); - onClose(); + props.onClose(); }; return ( - - - {title} - - - {message} - - - - - - - + + {message} + ); } diff --git a/src/equicordplugins/profileSets/components/presetManager.tsx b/src/equicordplugins/profileSets/components/presetManager.tsx index 74f2c5bc8..7207a7525 100644 --- a/src/equicordplugins/profileSets/components/presetManager.tsx +++ b/src/equicordplugins/profileSets/components/presetManager.tsx @@ -7,8 +7,7 @@ import { Button } from "@components/Button"; import { Heading } from "@components/Heading"; import { classes } from "@utils/misc"; -import { openModal } from "@utils/modal"; -import { React, SelectedGuildStore, TextInput, useStateFromStores } from "@webpack/common"; +import { openModal,React, SelectedGuildStore, TextInput, useStateFromStores } from "@webpack/common"; import { cl, settings } from "../index"; import { exportPresets, ImportDecision, importPresets, savePreset } from "../utils/actions"; diff --git a/src/equicordplugins/questify/components/settingsModal.tsx b/src/equicordplugins/questify/components/settingsModal.tsx index 4b741c9d3..2a8019a25 100644 --- a/src/equicordplugins/questify/components/settingsModal.tsx +++ b/src/equicordplugins/questify/components/settingsModal.tsx @@ -5,8 +5,8 @@ */ import PluginModal from "@components/settings/tabs/plugins/PluginModal"; -import { openModal } from "@utils/modal"; import type { Plugin } from "@utils/types"; +import { openModal } from "@webpack/common"; import { promptToRestartIfDirty } from "../settings/restartTracking"; import { setSettingsModalOpen } from "../state"; diff --git a/src/equicordplugins/quoter/index.tsx b/src/equicordplugins/quoter/index.tsx index d41104617..6868ababf 100644 --- a/src/equicordplugins/quoter/index.tsx +++ b/src/equicordplugins/quoter/index.tsx @@ -5,14 +5,12 @@ */ import { definePluginSettings } from "@api/Settings"; -import { BaseText } from "@components/BaseText"; import { FormSwitch } from "@components/FormSwitch"; import { Devs, EquicordDevs } from "@utils/constants"; import { getCurrentChannel } from "@utils/discord"; -import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; import definePlugin, { OptionType } from "@utils/types"; -import { Message } from "@vencord/discord-types"; -import { Button, IconUtils, Menu, TextInput, UploadHandler, useEffect, useState } from "@webpack/common"; +import { Message, RenderModalProps } from "@vencord/discord-types"; +import { IconUtils, Menu, Modal, openModal, TextInput, UploadHandler, useEffect, useState } from "@webpack/common"; import { QuoteIcon } from "./components/QuoteIcon"; import { QuoteFont } from "./types"; @@ -89,7 +87,7 @@ export default definePlugin({ } }); -function QuoteModal({ message, ...props }: ModalProps & { message: Message; }) { +function QuoteModal({ message, ...props }: RenderModalProps & { message: Message; }) { const [gray, setGray] = useState(settings.store.grayscale); const [showWatermark, setShowWatermark] = useState(settings.store.showWatermark); const [saveAsGif, setSaveAsGif] = useState(settings.store.saveAsGif); @@ -166,49 +164,48 @@ function QuoteModal({ message, ...props }: ModalProps & { message: Message; }) { }; return ( - - - - Catch Them In 4K. - - - - - Quote preview + + Quote preview - - - - {showWatermark && ( -
- -
- )} - -
- - + + + + {showWatermark && ( +
+
- - + )} + ); } diff --git a/src/equicordplugins/recentDMSwitcher/index.tsx b/src/equicordplugins/recentDMSwitcher/index.tsx index 48e5977fa..44bf24a8f 100644 --- a/src/equicordplugins/recentDMSwitcher/index.tsx +++ b/src/equicordplugins/recentDMSwitcher/index.tsx @@ -10,9 +10,8 @@ import * as DataStore from "@api/DataStore"; import { definePluginSettings } from "@api/Settings"; import { EquicordDevs, IS_MAC } from "@utils/constants"; import { classNameFactory } from "@utils/css"; -import { closeModal, openModal } from "@utils/modal"; import definePlugin, { makeRange, OptionType } from "@utils/types"; -import { Button, ChannelRouter, ChannelStore, IconUtils, React, RelationshipStore, SelectedChannelStore, Toasts, UserStore } from "@webpack/common"; +import { Button, ChannelRouter, ChannelStore, closeModal, IconUtils, openModal,React, RelationshipStore, SelectedChannelStore, Toasts, UserStore } from "@webpack/common"; const STORAGE_KEY = "RDMSwitch_history"; diff --git a/src/equicordplugins/remix/RemixModal.tsx b/src/equicordplugins/remix/RemixModal.tsx index c77414f47..1ad9912cc 100644 --- a/src/equicordplugins/remix/RemixModal.tsx +++ b/src/equicordplugins/remix/RemixModal.tsx @@ -4,9 +4,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { BaseText } from "@components/BaseText"; -import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; -import { Button } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal, React } from "@webpack/common"; import { sendRemix } from "."; import { brushCanvas, canvas, cropCanvas, ctx, exportImg, shapeCanvas } from "./editor/components/Canvas"; @@ -15,7 +14,7 @@ import { resetBounds } from "./editor/tools/crop"; import { SendIcon } from "./icons/SendIcon"; type Props = { - modalProps: ModalProps; + modalProps: RenderModalProps; close: () => void; url?: string; }; @@ -38,18 +37,28 @@ async function closeModal(closeFunc: () => void, save?: boolean) { export default function RemixModal({ modalProps, close, url }: Props) { return ( - - - Remix - closeModal(close)} /> - - - - - - - - - + + Send + + ) as any, + variant: "primary", + onClick: () => closeModal(close, true) + }, + { + text: "Close", + variant: "dangerPrimary", + onClick: () => closeModal(close) + } + ]} + > + + ); } diff --git a/src/equicordplugins/remix/index.tsx b/src/equicordplugins/remix/index.tsx index a03d89d09..23d1042c1 100644 --- a/src/equicordplugins/remix/index.tsx +++ b/src/equicordplugins/remix/index.tsx @@ -8,10 +8,9 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co import { disableStyle, enableStyle } from "@api/Styles"; import { PaintbrushIcon } from "@components/Icons"; import { EquicordDevs } from "@utils/constants"; -import { closeModal, openModal } from "@utils/modal"; import definePlugin from "@utils/types"; import { extractAndLoadChunksLazy } from "@webpack"; -import { ChannelStore, DraftType, FluxDispatcher, Menu, PendingReplyStore, SelectedChannelStore, UploadHandler } from "@webpack/common"; +import { ChannelStore, closeModal, DraftType, FluxDispatcher, Menu, openModal,PendingReplyStore, SelectedChannelStore, UploadHandler } from "@webpack/common"; import RemixModal from "./RemixModal"; import css from "./styles.css?managed"; diff --git a/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx b/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx index 95f4348af..d9126e8bf 100644 --- a/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx +++ b/src/equicordplugins/scheduledMessages/components/ScheduleTimeModal.tsx @@ -8,9 +8,9 @@ import { Button } from "@components/Button"; import ErrorBoundary from "@components/ErrorBoundary"; import { Heading } from "@components/Heading"; import { classNameFactory } from "@utils/css"; -import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; +import { RenderModalProps } from "@vencord/discord-types"; import { findByPropsLazy } from "@webpack"; -import { ChannelStore, DraftType, showToast, TextInput, Toasts, UploadManager, useState } from "@webpack/common"; +import { ChannelStore, closeModal, DraftType, Modal, openModal, showToast, TextInput, Toasts, UploadManager, useState } from "@webpack/common"; import { ScheduledAttachment } from "../types"; import { addScheduledMessage, getChannelDisplayInfo } from "../utils"; @@ -23,7 +23,7 @@ function ScheduleTimeModalInner({ channelId, content, attachments, rootProps, cl channelId: string; content: string; attachments?: ScheduledAttachment[]; - rootProps: ModalProps; + rootProps: RenderModalProps; close: () => void; }) { const [scheduleType, setScheduleType] = useState<"delay" | "time">("delay"); @@ -69,74 +69,78 @@ function ScheduleTimeModalInner({ channelId, content, attachments, rootProps, cl }; return ( - - - Schedule Message - - + +
+ {avatar && } + + Scheduling for: {isDM ? name : `#${name}`} + +
- -
- {avatar && } - - Scheduling for: {isDM ? name : `#${name}`} - + Schedule Type +
+ + +
+ + {scheduleType === "delay" ? ( + <> + Delay (minutes) + + + ) : ( + <> + Date & Time + setScheduledDateTime(e.target.value)} + min={new Date().toISOString().slice(0, 16)} + /> + + )} + + {error && ( +
+ + {error}
- - Schedule Type -
- - -
- - {scheduleType === "delay" ? ( - <> - Delay (minutes) - - - ) : ( - <> - Date & Time - setScheduledDateTime(e.target.value)} - min={new Date().toISOString().slice(0, 16)} - /> - - )} - - {error && ( -
- - {error} -
- )} - - - - - - - + )} + ); } diff --git a/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx b/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx index 1c41e9dbe..0fb99f605 100644 --- a/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx +++ b/src/equicordplugins/scheduledMessages/components/ViewScheduledModal.tsx @@ -6,10 +6,9 @@ import { Button } from "@components/Button"; import ErrorBoundary from "@components/ErrorBoundary"; -import { Heading } from "@components/Heading"; import { classNameFactory } from "@utils/css"; -import { closeModal, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; -import { ChannelStore, showToast, Toasts, useState } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { ChannelStore, closeModal, Modal, openModal, showToast, Toasts, useState } from "@webpack/common"; import { clearAllScheduledMessages, getChannelDisplayInfo, getScheduledMessages, removeScheduledMessage } from "../utils"; import { CalendarIcon, TimerIcon } from "./Icons"; @@ -17,7 +16,7 @@ import { CalendarIcon, TimerIcon } from "./Icons"; const cl = classNameFactory("vc-scheduled-msg-"); interface ViewScheduledModalProps { - rootProps: ModalProps; + rootProps: RenderModalProps; close: () => void; } @@ -36,69 +35,74 @@ function ViewScheduledModalInner({ rootProps, close }: ViewScheduledModalProps) showToast("All scheduled messages cleared", Toasts.Type.SUCCESS); }; + const actions = [ + { + text: "Close", + variant: "secondary", + onClick: close + } + ]; + + if (messages.length > 0) { + actions.unshift({ + text: "Clear All", + variant: "dangerPrimary", + onClick: handleClearAll + }); + } + return ( - - - Scheduled Messages - {messages.length > 0 && ( - - )} - - + + {!messages.length ? ( +
+ + No scheduled messages +
+ ) : ( +
+ {messages.map(msg => { + const { name, avatar } = getChannelDisplayInfo(msg.channelId); + const channel = ChannelStore.getChannel(msg.channelId); + if (!channel) return null; - - {!messages.length ? ( -
- - No scheduled messages -
- ) : ( -
- {messages.map(msg => { - const { name, avatar } = getChannelDisplayInfo(msg.channelId); - const channel = ChannelStore.getChannel(msg.channelId); - if (!channel) return null; + const isDM = channel.isPrivate(); + const displayContent = msg.content.length > 200 + ? msg.content.slice(0, 200) + "..." + : msg.content; - const isDM = channel.isPrivate(); - const displayContent = msg.content.length > 200 - ? msg.content.slice(0, 200) + "..." - : msg.content; - - return ( -
-
-
- {avatar && } - - {isDM ? name : `#${name}`} - -
-
- - {new Date(msg.scheduledTime).toLocaleString()} -
-
{displayContent}
+ return ( +
+
+
+ {avatar && } + + {isDM ? name : `#${name}`} +
- +
+ + {new Date(msg.scheduledTime).toLocaleString()} +
+
{displayContent}
- ); - })} -
- )} - - - - - - + +
+ ); + })} +
+ )} + ); } diff --git a/src/equicordplugins/sekaiStickers/Components/Picker.tsx b/src/equicordplugins/sekaiStickers/Components/Picker.tsx index 4a50e703d..1be2c7239 100644 --- a/src/equicordplugins/sekaiStickers/Components/Picker.tsx +++ b/src/equicordplugins/sekaiStickers/Components/Picker.tsx @@ -4,13 +4,12 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { BaseText } from "@components/BaseText"; import { Flex } from "@components/Flex"; import { characters } from "@equicordplugins/sekaiStickers/characters.json"; -import { ModalCloseButton, ModalContent, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; -import { React, ScrollerThin, TextInput } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { Modal,React, ScrollerThin, TextInput } from "@webpack/common"; -export default function CharSelectModal({ modalProps, setCharacter }: { modalProps: ModalProps; setCharacter?: any; }) { +export default function CharSelectModal({ modalProps, setCharacter }: { modalProps: RenderModalProps; setCharacter?: any; }) { const [search, setSearch] = React.useState(""); const memoedSearchChar = React.useMemo(() => { @@ -30,22 +29,15 @@ export default function CharSelectModal({ modalProps, setCharacter }: { modalPro }); }, [search, characters]); return ( - - - Select character menu - - - - - setSearch(e)} /> - -
- {memoedSearchChar} -
-
-
- -
-
+ + + setSearch(e)} /> + +
+ {memoedSearchChar} +
+
+
+
); } diff --git a/src/equicordplugins/sekaiStickers/Components/SekaiStickersModal.tsx b/src/equicordplugins/sekaiStickers/Components/SekaiStickersModal.tsx index 3b75dcbb9..da0465f84 100644 --- a/src/equicordplugins/sekaiStickers/Components/SekaiStickersModal.tsx +++ b/src/equicordplugins/sekaiStickers/Components/SekaiStickersModal.tsx @@ -4,18 +4,17 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -import { BaseText } from "@components/BaseText"; import { Flex } from "@components/Flex"; import { FormSwitch } from "@components/FormSwitch"; import { Heading } from "@components/Heading"; import { characters } from "@equicordplugins/sekaiStickers/characters.json"; -import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal"; -import { Button, ChannelStore, React, SelectedChannelStore, Slider, TextArea, UploadHandler } from "@webpack/common"; +import { RenderModalProps } from "@vencord/discord-types"; +import { ChannelStore, Modal, openModal, React, SelectedChannelStore, Slider, TextArea, UploadHandler } from "@webpack/common"; import Canvas from "./Canvas"; import CharSelectModal from "./Picker"; -export default function SekaiStickersModal({ modalProps, settings }: { modalProps: ModalProps; settings: any; }) { +export default function SekaiStickersModal({ modalProps, settings }: { modalProps: RenderModalProps; settings: any; }) { const [text, setText] = React.useState("奏でーかわいい"); const [character, setChracter] = React.useState(49); const [fontSize, setFontSize] = React.useState(characters[character].defaultText.s); @@ -97,45 +96,51 @@ export default function SekaiStickersModal({ modalProps, settings }: { modalProp } }; return ( - - - Sekai Stickers - - - - -
- - Text Y Pos - { va = Math.round(va); setPosition({ x: position.x, y: curve ? 256 + fontSize * 3 - va : 256 - va }); }} initialValue={curve ? 256 - position.y + fontSize * 3 : 256 - position.y} orientation={"vertical"} onValueRender={va => String(Math.round(va))} /> - Text XZ Pos - { va = Math.round(va); setPosition({ y: position.y, x: va }); }} initialValue={position.x} orientation={"horizontal"} onValueRender={(v: number) => String(Math.round(v))} /> -
-
- Text -