Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
update plugins: Anammox, betterPinDMs, FastMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
verticalsync committed Mar 2, 2024
1 parent 4187437 commit 8fd1193
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 164 deletions.
8 changes: 8 additions & 0 deletions src/suncordplugins/Anammox/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Anammox

Removes Nitro-exclusive stuff from various places:
- The shops above private chats
- The gift button in the chat box
- The "billing" section in settings

While this can be done with css, a plugin is able to do it much more thorougly — for example, the shops are still accessible via keyboard navigation.
11 changes: 2 additions & 9 deletions src/suncordplugins/Anammox/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { definePluginSettings } from "@api/Settings";

Check failure on line 1 in src/suncordplugins/Anammox/index.ts

View workflow job for this annotation

GitHub Actions / test

Missing header
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";

export const settings = definePluginSettings({
Expand Down Expand Up @@ -38,7 +31,7 @@ export const settings = definePluginSettings({
export default definePlugin({
name: "Anammox",
description: "A microbial process that plays an important part in the nitrogen cycle",
authors: [Devs.Kyuuhachi],
authors: [{ id: 236588665420251137n, name: "Kyuuhachi" }],
settings,

patches: [
Expand Down Expand Up @@ -97,7 +90,7 @@ export default definePlugin({
{ // Emoji list
find: "useEmojiGrid:function()",
replacement: {
match: /(\w+)=\w+.default.isEmojiCategoryNitroLocked\(\{[^}]*\}\);/,
match: /(\w+)=!\w+&&\w+.default.isEmojiCategoryNitroLocked\(\{[^}]*\}\);/,
replace: "$&$1||"
},
predicate: () => settings.store.emojiList,
Expand Down
10 changes: 4 additions & 6 deletions src/suncordplugins/FastMenu/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# FastMenu

Several patches to speed up the loading of the main settings menu:

- Remove the fade-zoom animation when opening it.
- Remove another animation for fading in the menu contents (why do they have two).
- Eagerly load the menu contents; without this the first time has an extra delay.
- Remove the fade-zoom animation when opening it.
- Remove another animation for fading in the menu contents (why do they have two).
- Eagerly load the menu contents; without this the first time has an extra delay.

### A note on themes

If you use a theme like _Modal settings window_, this plugin interferes with
If you use a theme like *Modal settings window*, this plugin interferes with
that since it uses `visibility` instead of `opacity` to hide background layers.
I'm undecided on whether to switch to `opacity` for compatibility or stick with
`visibility` because that's the correct way to do it.
33 changes: 9 additions & 24 deletions src/suncordplugins/FastMenu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import { definePluginSettings } from "@api/Settings";

Check failure on line 1 in src/suncordplugins/FastMenu/index.tsx

View workflow job for this annotation

GitHub Actions / test

Missing header
import { classNameFactory } from "@api/Styles";
import { Devs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, wreq } from "@webpack";
import { ComponentDispatch, Forms, useEffect, useRef } from "@webpack/common";
Expand All @@ -21,21 +14,20 @@ const settings = definePluginSettings({
type: OptionType.BOOLEAN,
default: true,
onChange(val) {
if (val) eagerLoad();
if(val) eagerLoad();
}
},
});

const lazyLayers: string[] = [];
function eagerLoad() {
// @ts-ignore
lazyLayers.forEach(wreq.el);
}

export default definePlugin({
name: "FastMenu",
description: "Makes the settings menu open faster.",
authors: [Devs.Kyuuhachi],
authors: [{ id: 236588665420251137n, name: "Kyuuhachi" }],
settings,

patches: [
Expand All @@ -62,16 +54,10 @@ export default definePlugin({
},
{ // load menu stuff on hover, not on click
find: "Messages.USER_SETTINGS_WITH_BUILD_OVERRIDE.format",
replacement: ((module_id: string) => [
{
match: /handleOpenSettingsContextMenu.{0,250}?\i\.el\(("\d+")\)\.then/,
replace: (text, w) => (module_id = w, text)
},
{
match: /(?<=Messages\.USER_SETTINGS,)/,
replace: () => `async onMouseEnter(){let r=Vencord.Webpack.wreq;await r.el(${module_id});r(${module_id});},`,
},
])(null as any),
replacement: {
match: /(?<=handleOpenSettingsContextMenu.{0,250}?\i\.el\(("\d+")\)\.then.*?Messages\.USER_SETTINGS,)(?=onClick:)/,
replace: "onMouseEnter(){let r=Vencord.Webpack.wreq;r.el($1).then(r.bind(r,$1));},"
},
predicate: () => settings.store.eagerLoad,
},
],
Expand All @@ -97,18 +83,17 @@ export default definePlugin({
style={{ visibility: hidden ? "hidden" : "visible" }}
{...props}
/>;
if (baseLayer) return node;
// @ts-ignore
if(baseLayer) return node;
else return <Forms.FocusLock containerRef={containerRef}>{node}</Forms.FocusLock>;
},

lazyLayer(moduleId: string, name: string) {
if (name !== "CollectiblesShop")
if(name !== "CollectiblesShop")
lazyLayers.push(moduleId);
},

start() {
if (settings.store.eagerLoad)
if(settings.store.eagerLoad)
eagerLoad();
},
});
75 changes: 38 additions & 37 deletions src/suncordplugins/betterPinDMs/components/CreateCategoryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const useCategory = (categoryId: string | null, initalChannelId: string | null)
id: Toasts.genId(),
name: `Pin Category ${categories.length + 1}`,
color: 10070709,
colapsed: false,
collapsed: false,
channels: [initalChannelId]
});
}, []);
Expand All @@ -70,7 +70,8 @@ export function NewCategoryModal({ categoryId, modalProps, initalChannelId }: Pr

if (!category) return null;

const onClick = async () => {
const onSave = async (e: React.FormEvent<HTMLFormElement> | React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
e.preventDefault();
if (!categoryId)
await createCategory(category);
else
Expand All @@ -86,41 +87,41 @@ export function NewCategoryModal({ categoryId, modalProps, initalChannelId }: Pr
<Text variant="heading-lg/semibold" style={{ flexGrow: 1 }}>{categoryId ? "Edit" : "New"} Category</Text>
</ModalHeader>

<ModalContent className={cl("content")}>
<Forms.FormSection>
<Forms.FormTitle>Name</Forms.FormTitle>
<TextInput
value={category.name}
onChange={e => setCategory({ ...category, name: e })}
/>
</Forms.FormSection>

<Forms.FormDivider />

<Forms.FormSection>
<Forms.FormTitle>Color</Forms.FormTitle>
<ColorPickerWithSwatches
key={category.name}
defaultColor={DEFAULT_COLOR}
colors={SWATCHES}
onChange={c => setCategory({ ...category, color: c! })}
value={category.color}
renderDefaultButton={() => null}
renderCustomButton={() => (
<ColorPicker
color={category.color}
onChange={c => setCategory({ ...category, color: c! })}
key={category.name}
showEyeDropper={false}
/>
)}
/>
</Forms.FormSection>
</ModalContent>

<ModalFooter>
<Button onClick={onClick} disabled={!category.name}>{categoryId ? "Save" : "Create"}</Button>
</ModalFooter>
{/* form is here so when you press enter while in the text input it submits */}
<form onSubmit={onSave}>
<ModalContent className={cl("content")}>
<Forms.FormSection>
<Forms.FormTitle>Name</Forms.FormTitle>
<TextInput
value={category.name}
onChange={e => setCategory({ ...category, name: e })}
/>
</Forms.FormSection>
<Forms.FormDivider />
<Forms.FormSection>
<Forms.FormTitle>Color</Forms.FormTitle>
<ColorPickerWithSwatches
key={category.name}
defaultColor={DEFAULT_COLOR}
colors={SWATCHES}
onChange={c => setCategory({ ...category, color: c! })}
value={category.color}
renderDefaultButton={() => null}
renderCustomButton={() => (
<ColorPicker
color={category.color}
onChange={c => setCategory({ ...category, color: c! })}
key={category.name}
showEyeDropper={false}
/>
)}
/>
</Forms.FormSection>
</ModalContent>
<ModalFooter>
<Button type="submit" onClick={onSave} disabled={!category.name}>{categoryId ? "Save" : "Create"}</Button>
</ModalFooter>
</form>
</ModalRoot>
);
}
Expand Down
38 changes: 30 additions & 8 deletions src/suncordplugins/betterPinDMs/components/contextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import { addContextMenuPatch, findGroupChildrenByChildId, NavContextMenuPatchCallback, removeContextMenuPatch } from "@api/ContextMenu";
import { Menu } from "@webpack/common";

import { forceUpdate } from "..";
import { addChannelToCategory, categories, isPinned, removeChannelFromCategory } from "../data";
import { addChannelToCategory, canMoveChannelInDirection, categories, isPinned, moveChannel, removeChannelFromCategory } from "../data";
import { forceUpdate, settings } from "../index";
import { openCategoryModal } from "./CreateCategoryModal";

function PinMenuItem(channelId: string) {
Expand Down Expand Up @@ -43,12 +43,34 @@ function PinMenuItem(channelId: string) {
)}

{pinned && (
<Menu.MenuItem
id="unpin-dm"
label="Unpin DM"
color="danger"
action={() => removeChannelFromCategory(channelId).then(() => forceUpdate())}
/>
<>
<Menu.MenuItem
id="unpin-dm"
label="Unpin DM"
color="danger"
action={() => removeChannelFromCategory(channelId).then(() => forceUpdate())}
/>

{
!settings.store.sortDmsByNewestMessage && canMoveChannelInDirection(channelId, -1) && (
<Menu.MenuItem
id="move-up"
label="Move Up"
action={() => moveChannel(channelId, -1).then(() => forceUpdate())}
/>
)
}

{
!settings.store.sortDmsByNewestMessage && canMoveChannelInDirection(channelId, 1) && (
<Menu.MenuItem
id="move-down"
label="Move Down"
action={() => moveChannel(channelId, 1).then(() => forceUpdate())}
/>
)
}
</>
)}

</Menu.MenuItem>
Expand Down
25 changes: 24 additions & 1 deletion src/suncordplugins/betterPinDMs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,27 @@
*/

export const DEFAULT_COLOR = 10070709;
export const SWATCHES = [1752220, 3066993, 3447003, 10181046, 15277667, 15844367, 15105570, 15158332, 9807270, 6323595, 1146986, 2067276, 2123412, 7419530, 11342935, 12745742, 11027200, 10038562, 9936031, 5533306];

export const SWATCHES = [
1752220,
3066993,
3447003,
10181046,
15277667,
15844367,
15105570,
15158332,
9807270,
6323595,

1146986,
2067276,
2123412,
7419530,
11342935,
12745742,
11027200,
10038562,
9936031,
5533306
];
Loading

0 comments on commit 8fd1193

Please sign in to comment.