Settings: Migrate Off Options Mostly
This commit is contained in:
parent
2454287064
commit
575cb52790
8 changed files with 108 additions and 100 deletions
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
|
||||
import { addMessagePopoverButton, removeMessagePopoverButton } from "@api/MessagePopover";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { disableStyle, enableStyle } from "@api/Styles";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
|
@ -52,12 +53,12 @@ function findReplies(message: Message) {
|
|||
if (other.messageReference?.message_id === message.id) {
|
||||
found.push(other);
|
||||
}
|
||||
if (Vencord.Settings.plugins.FindReply.includePings) {
|
||||
if (settings.store.includePings) {
|
||||
if (other.content?.includes(`<@${message.author.id}>`)) {
|
||||
found.push(other);
|
||||
}
|
||||
}
|
||||
if (Vencord.Settings.plugins.FindReply.includeAuthor) {
|
||||
if (settings.store.includeAuthor) {
|
||||
if (messages.find(m => m.id === other.messageReference?.message_id)?.author.id === message.author.id) {
|
||||
found.push(other);
|
||||
}
|
||||
|
|
@ -66,16 +67,39 @@ function findReplies(message: Message) {
|
|||
return found;
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
includePings: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Will also search for messages that @ the author directly",
|
||||
default: false,
|
||||
restartNeeded: false
|
||||
},
|
||||
includeAuthor: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Will also search for messages that reply to the author in general, not just that exact message",
|
||||
default: false,
|
||||
restartNeeded: false
|
||||
},
|
||||
hideButtonIfNoReply: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Hides the button if there are no replies to the message",
|
||||
default: true,
|
||||
restartNeeded: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
export default definePlugin({
|
||||
name: "FindReply",
|
||||
description: "Jumps to the earliest reply to a message in a channel (lets you follow past conversations more easily).",
|
||||
authors: [Devs.newwares],
|
||||
settings,
|
||||
start() {
|
||||
enableStyle(styles);
|
||||
addMessagePopoverButton("vc-findreply", message => {
|
||||
if (!message.id) return null;
|
||||
const replies = findReplies(message);
|
||||
if (Vencord.Settings.plugins.FindReply.hideButtonIfNoReply && !replies.length) return null;
|
||||
if (settings.store.hideButtonIfNoReply && !replies.length) return null;
|
||||
return {
|
||||
label: "Jump to Reply",
|
||||
icon: FindReplyIcon,
|
||||
|
|
@ -132,24 +156,4 @@ export default definePlugin({
|
|||
element?.remove();
|
||||
disableStyle(styles);
|
||||
},
|
||||
options: {
|
||||
includePings: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Will also search for messages that @ the author directly",
|
||||
default: false,
|
||||
restartNeeded: false
|
||||
},
|
||||
includeAuthor: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Will also search for messages that reply to the author in general, not just that exact message",
|
||||
default: false,
|
||||
restartNeeded: false
|
||||
},
|
||||
hideButtonIfNoReply: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Hides the button if there are no replies to the message",
|
||||
default: true,
|
||||
restartNeeded: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ const StickerPackMetadata = ({ meta, hoveredStickerPackId, setHoveredStickerPack
|
|||
);
|
||||
};
|
||||
|
||||
export const Settings = () => {
|
||||
export const Packs = () => {
|
||||
const [stickerPackMetas, setstickerPackMetas] = React.useState<StickerPackMeta[]>([]);
|
||||
const [addStickerUrl, setAddStickerUrl] = React.useState<string>("");
|
||||
const [addStickerHtml, setAddStickerHtml] = React.useState<string>("");
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import { sendSticker } from "../upload";
|
|||
import { clPicker, FFmpegStateContext } from "../utils";
|
||||
import { CategoryImage, CategoryScroller, CategoryWrapper, StickerCategory } from "./categories";
|
||||
import { CancelIcon, CogIcon, IconContainer, RecentlyUsedIcon, SearchIcon } from "./icons";
|
||||
import { addRecentSticker, getRecentStickers, Header, RECENT_STICKERS_ID, RECENT_STICKERS_TITLE, Settings } from "./misc";
|
||||
import { addRecentSticker, getRecentStickers, Header, Packs, RECENT_STICKERS_ID, RECENT_STICKERS_TITLE } from "./misc";
|
||||
|
||||
const debounceQueryChange = debounce((cb: Function, ...args: any) => cb(...args), 150);
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ export const PickerSidebar = ({ packMetas, onPackSelect }: SidebarProps) => {
|
|||
<HeadingPrimary>Stickers+</HeadingPrimary>
|
||||
</ModalHeader>
|
||||
<ModalContent>
|
||||
<Settings />
|
||||
<Packs />
|
||||
</ModalContent>
|
||||
</ModalRoot>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -6,29 +6,31 @@
|
|||
|
||||
import "./style.css";
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { FFmpeg } from "@ffmpeg/ffmpeg";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Channel } from "@vencord/discord-types";
|
||||
import { React } from "@webpack/common";
|
||||
|
||||
import { PickerContent, PickerHeader, PickerSidebar, Settings, Wrapper } from "./components";
|
||||
import { Packs, PickerContent, PickerHeader, PickerSidebar, Wrapper } from "./components";
|
||||
import { getStickerPack, getStickerPackMetas } from "./stickers";
|
||||
import { StickerPack, StickerPackMeta } from "./types";
|
||||
import { cl, FFmpegStateContext, loadFFmpeg } from "./utils";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
packs: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "Packs",
|
||||
component: Packs
|
||||
}
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "MoreStickers",
|
||||
description: "Adds sticker packs from other social media platforms. (e.g. LINE)",
|
||||
authors: [EquicordDevs.Leko, Devs.Arjix],
|
||||
|
||||
options: {
|
||||
settings: {
|
||||
type: OptionType.COMPONENT,
|
||||
description: "Packs",
|
||||
component: Settings
|
||||
}
|
||||
},
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.vc-more-stickers-picker-container>div:first-child {
|
||||
.vc-more-stickers-picker-container > div:first-child {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-flow: wrap;
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.vc-more-stickers-foreign-object>img {
|
||||
.vc-more-stickers-foreign-object > img {
|
||||
text-indent: -9999px;
|
||||
align-items: center;
|
||||
background-color: var(--background-primary);
|
||||
|
|
@ -99,13 +99,13 @@
|
|||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.vc-more-stickers-category-scroller> :first-child {
|
||||
.vc-more-stickers-category-scroller > :first-child {
|
||||
inset: 8px;
|
||||
contain: layout;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.vc-more-stickers-category-scroller> :last-child {
|
||||
.vc-more-stickers-category-scroller > :last-child {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
min-height: 0;
|
||||
|
|
@ -430,7 +430,7 @@
|
|||
background-color: var(--green-300);
|
||||
}
|
||||
|
||||
.vc-more-stickers-picker-settings-cog>svg {
|
||||
.vc-more-stickers-picker-settings-cog > svg {
|
||||
color: var(--green-360) !important;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
|
@ -438,7 +438,7 @@
|
|||
}
|
||||
|
||||
/* prettier-ignore */
|
||||
.vc-more-stickers-picker-settings-cog-active>svg {
|
||||
.vc-more-stickers-picker-settings-cog-active > svg {
|
||||
color: var(--white-360) !important;
|
||||
}
|
||||
|
||||
|
|
@ -492,9 +492,8 @@
|
|||
}
|
||||
|
||||
.vc-more-stickers-settings .tab-bar-item {
|
||||
margin-right: 16px;
|
||||
margin-right: 2px;
|
||||
padding-bottom: 4px;
|
||||
margin-bottom: -4px;
|
||||
}
|
||||
|
||||
.vc-more-stickers-pack-title {
|
||||
|
|
@ -502,4 +501,4 @@
|
|||
font-size: 8pt;
|
||||
font-weight: 600;
|
||||
color: var(--text-default);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,15 +16,31 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { copyWithToast } from "@utils/misc";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
bothStyles: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show both role dot and coloured names",
|
||||
restartNeeded: true,
|
||||
default: false,
|
||||
},
|
||||
copyRoleColorInProfilePopout: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Allow click on role dot in profile popout to copy role color",
|
||||
restartNeeded: true,
|
||||
default: false
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "BetterRoleDot",
|
||||
authors: [Devs.Ven, Devs.AutumnVN],
|
||||
description: "Copy role colour on RoleDot (accessibility setting) click. Also allows using both RoleDot and coloured names simultaneously",
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
|
|
@ -38,7 +54,7 @@ export default definePlugin({
|
|||
find: '"dot"===',
|
||||
all: true,
|
||||
noWarn: true,
|
||||
predicate: () => Settings.plugins.BetterRoleDot.bothStyles,
|
||||
predicate: () => settings.store.bothStyles,
|
||||
replacement: {
|
||||
match: /"(?:username|dot)"===\i(?!\.\i)/g,
|
||||
replace: "true",
|
||||
|
|
@ -48,7 +64,7 @@ export default definePlugin({
|
|||
{
|
||||
find: "#{intl::ADD_ROLE_A11Y_LABEL}",
|
||||
all: true,
|
||||
predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles,
|
||||
predicate: () => settings.store.copyRoleColorInProfilePopout && !settings.store.bothStyles,
|
||||
noWarn: true,
|
||||
replacement: {
|
||||
match: /"dot"===\i/,
|
||||
|
|
@ -58,7 +74,7 @@ export default definePlugin({
|
|||
{
|
||||
find: ".roleVerifiedIcon",
|
||||
all: true,
|
||||
predicate: () => Settings.plugins.BetterRoleDot.copyRoleColorInProfilePopout && !Settings.plugins.BetterRoleDot.bothStyles,
|
||||
predicate: () => settings.store.copyRoleColorInProfilePopout && !settings.store.bothStyles,
|
||||
noWarn: true,
|
||||
replacement: {
|
||||
match: /"dot"===\i/,
|
||||
|
|
@ -67,21 +83,6 @@ export default definePlugin({
|
|||
}
|
||||
],
|
||||
|
||||
options: {
|
||||
bothStyles: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Show both role dot and coloured names",
|
||||
restartNeeded: true,
|
||||
default: false,
|
||||
},
|
||||
copyRoleColorInProfilePopout: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Allow click on role dot in profile popout to copy role color",
|
||||
restartNeeded: true,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
|
||||
copyToClipBoard(color: string) {
|
||||
copyWithToast(color);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ function setCss() {
|
|||
style.textContent = `
|
||||
.vc-nsfw-img [class^=imageContainer],
|
||||
.vc-nsfw-img [class^=wrapperPaused] {
|
||||
filter: blur(${Settings.plugins.BlurNSFW.blurAmount}px);
|
||||
filter: blur(${settings.store.blurAmount}px);
|
||||
transition: filter 0.2s;
|
||||
|
||||
&:hover {
|
||||
|
|
@ -24,36 +24,37 @@ function setCss() {
|
|||
`;
|
||||
}
|
||||
|
||||
const settings = definePluginSettings({
|
||||
blurAmount: {
|
||||
type: OptionType.NUMBER,
|
||||
description: "Blur Amount (in pixels)",
|
||||
default: 10,
|
||||
onChange: setCss
|
||||
},
|
||||
blurAllChannels: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Blur attachments in all channels (not just NSFW)",
|
||||
default: false
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "BlurNSFW",
|
||||
description: "Blur attachments in NSFW channels until hovered",
|
||||
authors: [Devs.Ven],
|
||||
isModified: true,
|
||||
settings,
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: "}renderEmbeds(",
|
||||
replacement: [{
|
||||
match: /\.container/,
|
||||
replace: "$&+(this.props.channel.nsfw || Vencord.Settings.plugins.BlurNSFW.blurAllChannels ? ' vc-nsfw-img': '')"
|
||||
replace: "$&+(this.props.channel.nsfw || $self.settings.store.blurAllChannels ? ' vc-nsfw-img': '')"
|
||||
}]
|
||||
}
|
||||
],
|
||||
|
||||
options: {
|
||||
blurAmount: {
|
||||
type: OptionType.NUMBER,
|
||||
description: "Blur Amount (in pixels)",
|
||||
default: 10,
|
||||
onChange: setCss
|
||||
},
|
||||
blurAllChannels: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Blur attachments in all channels (not just NSFW)",
|
||||
default: false
|
||||
}
|
||||
},
|
||||
|
||||
start() {
|
||||
style = document.createElement("style");
|
||||
style.id = "VcBlurNsfw";
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { useTimer } from "@utils/react";
|
||||
|
|
@ -26,33 +26,34 @@ import { React } from "@webpack/common";
|
|||
|
||||
import alignedChatInputFix from "./alignedChatInputFix.css?managed";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
format: {
|
||||
type: OptionType.SELECT,
|
||||
description: "The timer format. This can be any valid moment.js format",
|
||||
options: [
|
||||
{
|
||||
label: "30d 23:00:42",
|
||||
value: "stopwatch",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "30d 23h 00m 42s",
|
||||
value: "human"
|
||||
}
|
||||
]
|
||||
},
|
||||
});
|
||||
|
||||
export default definePlugin({
|
||||
name: "CallTimer",
|
||||
description: "Adds a timer to vcs",
|
||||
authors: [Devs.Ven],
|
||||
managedStyle: alignedChatInputFix,
|
||||
settings,
|
||||
|
||||
startTime: 0,
|
||||
interval: void 0 as NodeJS.Timeout | undefined,
|
||||
|
||||
options: {
|
||||
format: {
|
||||
type: OptionType.SELECT,
|
||||
description: "The timer format. This can be any valid moment.js format",
|
||||
options: [
|
||||
{
|
||||
label: "30d 23:00:42",
|
||||
value: "stopwatch",
|
||||
default: true
|
||||
},
|
||||
{
|
||||
label: "30d 23h 00m 42s",
|
||||
value: "human"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
patches: [{
|
||||
find: "renderConnectionStatus(){",
|
||||
replacement: {
|
||||
|
|
@ -73,6 +74,6 @@ export default definePlugin({
|
|||
deps: [channelId]
|
||||
});
|
||||
|
||||
return <p style={{ margin: 0, fontFamily: "var(--font-code)" }}>{formatDurationMs(time, Settings.plugins.CallTimer.format === "human")}</p>;
|
||||
return <p style={{ margin: 0, fontFamily: "var(--font-code)" }}>{formatDurationMs(time, settings.store.format === "human")}</p>;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue