Fix Some Bugs

This commit is contained in:
thororen1234 2025-02-02 22:50:39 -05:00
parent 7f4834d967
commit 01d6e7f771
5 changed files with 99 additions and 80 deletions

View file

@ -108,7 +108,7 @@ export default definePlugin({
},
{
// Emoji category list
find: "#{intl::EMOJI_CATEGORY_TOP_GUILD_EMOJI}",
find: "#{intl::EMOJI_CATEGORY_TOP_GUILD_EMOJI},{guildName:",
replacement: {
match: /(?<=(\i)\.unshift\((\i)\):)(?=\1\.push\(\2\))/,
replace: "$2.isNitroLocked||"

View file

@ -84,59 +84,71 @@ function BookmarkFolderOpenMenu(props: BookmarkProps) {
onClose={() => FluxDispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" })}
aria-label="Bookmark Folder Menu"
>
{bookmark.bookmarks.map((b, i) => <><Menu.MenuItem
key={`bookmark-folder-entry-${b.channelId}`}
id={`bookmark-folder-entry-${b.channelId}`}
label={<div style={{
display: "flex",
alignItems: "center",
gap: "0.25rem"
}}>
<span style={{ overflow: "hidden", textOverflow: "ellipsis" }}>
{b.name}
</span>
{bookmarkNotificationDot && <NotificationDot channelIds={[b.channelId]} />}
</div>}
icon={() => <BookmarkIcon bookmark={b} />}
showIconFirst={true}
action={() => switchChannel(b)} /><span>
(
bookmarkNotificationDot && <Menu.MenuGroup>
<Menu.MenuItem
key="mark-as-read"
id="mark-as-read"
label={getIntlMessage("MARK_AS_READ")}
disabled={!ReadStateStore.hasUnread(b.channelId)}
action={() => ReadStateUtils.ackChannel(ChannelStore.getChannel(b.channelId))} />
</Menu.MenuGroup>
)
</span><span>
{bookmark.bookmarks.map((b, i) => (
<Menu.MenuItem
key={`bookmark-folder-entry-${b.channelId}`}
id={`bookmark-folder-entry-${b.channelId}`}
label={
<div
style={{
display: "flex",
alignItems: "center",
gap: "0.25rem"
}}>
<span
style={{
overflow: "hidden",
textOverflow: "ellipsis"
}}>
{b.name}
</span>
{bookmarkNotificationDot && <NotificationDot channelIds={[b.channelId]} />}
</div>
}
icon={() => <BookmarkIcon bookmark={b} />}
showIconFirst={true}
action={() => switchChannel(b)}
>
{bookmarkNotificationDot && (
<Menu.MenuGroup>
<Menu.MenuItem
key="mark-as-read"
id="mark-as-read"
label={getIntlMessage("MARK_AS_READ")}
disabled={!ReadStateStore.hasUnread(b.channelId)}
action={() => ReadStateUtils.ackChannel(ChannelStore.getChannel(b.channelId))}
/>
</Menu.MenuGroup>
)}
<Menu.MenuGroup key="bookmarks">
<Menu.MenuItem
key="edit-bookmark"
id="edit-bookmark"
label="Edit Bookmark"
action={() => {
const key = openModal(modalProps => <EditModal
modalProps={modalProps}
modalKey={key}
bookmark={b}
onSave={name => {
const newBookmarks = [...bookmark.bookmarks];
newBookmarks[i].name = name;
methods.editBookmark(index, { bookmarks: newBookmarks });
closeModal(key);
}} />
const key = openModal(modalProps =>
<EditModal
modalProps={modalProps}
modalKey={key}
bookmark={b}
onSave={name => {
const newBookmarks = [...bookmark.bookmarks];
newBookmarks[i].name = name;
methods.editBookmark(index, { bookmarks: newBookmarks });
closeModal(key);
}}
/>
);
}} />
}}
/>
<Menu.MenuItem
key="delete-bookmark"
id="delete-bookmark"
label="Delete Bookmark"
action={() => {
methods.deleteBookmark(i, index);
}} />
}}
/>
<Menu.MenuItem
key="remove-bookmark-from-folder"
id="remove-bookmark-from-folder"
@ -144,14 +156,14 @@ function BookmarkFolderOpenMenu(props: BookmarkProps) {
action={() => {
const newBookmarks = [...bookmark.bookmarks];
newBookmarks.splice(i, 1);
methods.addBookmark(b);
methods.editBookmark(index, { bookmarks: newBookmarks });
}} />
}}
/>
</Menu.MenuGroup>
</span>
</>)}
</Menu.Menu >
</Menu.MenuItem>
))}
</Menu.Menu>
);
}

View file

@ -1,6 +1,6 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
@ -10,35 +10,10 @@ import { definePluginSettings } from "@api/Settings";
import { getUserSettingLazy } from "@api/UserSettings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { proxyLazy } from "@utils/lazy";
import definePlugin, { OptionType } from "@utils/types";
import { findComponentByCodeLazy } from "@webpack";
import { ChannelStore, Constants, Forms, MessageStore, RestAPI, Tooltip, useEffect, useState, useStateFromStores } from "@webpack/common";
import type { ComponentType, HTMLAttributes } from "react";
declare enum SpinnerTypes {
WANDERING_CUBES = "wanderingCubes",
CHASING_DOTS = "chasingDots",
PULSING_ELLIPSIS = "pulsingEllipsis",
SPINNING_CIRCLE = "spinningCircle",
SPINNING_CIRCLE_SIMPLE = "spinningCircleSimple",
LOW_MOTION = "lowMotion",
}
type Spinner = ComponentType<Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
type?: SpinnerTypes;
animated?: boolean;
className?: string;
itemClassName?: string;
"aria-label"?: string;
}> & {
Type: typeof SpinnerTypes;
};
const { Spinner } = proxyLazy(() => Forms as any as {
Spinner: Spinner,
SpinnerTypes: typeof SpinnerTypes;
});
import { ChannelStore, Constants, MessageStore, RestAPI, Tooltip, useEffect, useState, useStateFromStores } from "@webpack/common";
import type { ComponentType } from "react";
const MessageDisplayCompact = getUserSettingLazy("textAndImages", "messageDisplayCompact")!;
@ -104,7 +79,7 @@ export default definePlugin({
find: "#{intl::REPLY_QUOTE_MESSAGE_NOT_LOADED}",
replacement: {
// Should match two places
match: /(\i\.clickable),\{/g,
match: /(\i\.\i),\{(?=className:\i\(\)\(\i\.repliedTextPreview,\i\.clickable)/g,
replace: "$self.ReplyTooltip,{Component:$1,vcProps:arguments[0],"
},
predicate: () => settings.store.onReply,
@ -112,8 +87,8 @@ export default definePlugin({
{
find: "#{intl::MESSAGE_FORWARDED}",
replacement: {
match: /(null:.{0,20})(\i\.\i\i),\{/,
replace: "$1$self.ForwardTooltip,{Component:$2,vcProps:arguments[0],"
match: /(\i\.\i),\{(?=className:\i\.footerContainer)/g,
replace: "$self.ForwardTooltip,{Component:$1,vcProps:arguments[0],"
},
predicate: () => settings.store.onForward,
},
@ -159,9 +134,8 @@ function MessagePreview({ channelId, messageId }) {
const compact = settings.store.display === "compact" ? true : settings.store.display === "cozy" ? false : rawCompact;
// TODO handle load failure
if (!message) {
return <Spinner type={Spinner.Type.PULSING_ELLIPSIS} />;
return <span>Loading...</span>;
}
return <ChannelMessage

View file

@ -0,0 +1,32 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2025 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
export default definePlugin({
name: "MoreThemes",
description: "Enables Darker and Midnight themes",
authors: [Devs.Kyuuhachi],
patches: [
{ // matches twice: the settings menu and the settings context menu
find: '("appearance_settings")',
replacement: {
match: /\("appearance_settings"\)/,
replace: "$&||true"
},
all: true,
},
{ // make it actually save the setting instead of falling back to dark
find: ')("ThemeStore"))return',
replacement: {
match: /(?<=\)\("ThemeStore"\))(?=\)return)/,
replace: "&&false"
},
}
],
});