IgnoreCalls: Redo Setting

This commit is contained in:
thororen1234 2025-09-13 20:32:47 -04:00
parent f6ccaf2a65
commit 2eaa0bfbc4
No known key found for this signature in database
2 changed files with 25 additions and 17 deletions

View file

@ -6,18 +6,20 @@
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
import { definePluginSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles";
import { ErrorBoundary } from "@components/index";
import { EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import definePlugin, { makeRange, OptionType } from "@utils/types";
import { Channel } from "@vencord/discord-types";
import { FluxDispatcher, Menu, React, UserStore } from "@webpack/common";
const ignoredChannelIds = new Set<string>();
const ignoredChannelIds: string[] = [];
const cl = classNameFactory("vc-ignore-calls-");
const ContextMenuPatch: NavContextMenuPatchCallback = (children, { channel }: { channel: Channel; }) => {
if (!channel || (!channel.isDM() && !channel.isGroupDM())) return;
const [checked, setChecked] = React.useState(ignoredChannelIds.has(channel.id));
const [checked, setChecked] = React.useState(ignoredChannelIds.includes(channel.id));
children.push(
<Menu.MenuSeparator />,
@ -27,9 +29,9 @@ const ContextMenuPatch: NavContextMenuPatchCallback = (children, { channel }: {
checked={checked}
action={() => {
if (checked)
ignoredChannelIds.delete(channel.id);
ignoredChannelIds.includes(channel.id);
else
ignoredChannelIds.add(channel.id);
ignoredChannelIds.push(channel.id);
setChecked(!checked);
@ -42,8 +44,8 @@ const settings = definePluginSettings({
ignoreTimeout: {
type: OptionType.SLIDER,
description: "Timeout to click ignore",
markers: [0, 1000, 2500, 5000, 10000],
default: 2500,
markers: makeRange(0, 10000, 1000),
default: 5000,
stickToMarkers: true,
}
});
@ -53,6 +55,7 @@ export default definePlugin({
name: "IgnoreCalls",
description: "Allows you to ignore calls from specific users or dm groups.",
authors: [EquicordDevs.TheArmagan],
settings,
patches: [
{
find: "#{intl::INCOMING_CALL_ELLIPSIS}",
@ -62,11 +65,14 @@ export default definePlugin({
}
}
],
settings,
contextMenus: {
"user-context": ContextMenuPatch,
"gdm-context": ContextMenuPatch,
},
flux: {
async CALL_UPDATE({ channelId, ringing, messageId, region }: { channelId: string; ringing: string[]; messageId: string; region: string; }) {
setTimeout(() => {
if (!ignoredChannelIds.has(channelId)) return;
if (!ignoredChannelIds.includes(channelId)) return;
const currentUserId = UserStore.getCurrentUser().id;
if (ringing.includes(currentUserId)) {
return FluxDispatcher.dispatch({
@ -81,17 +87,15 @@ export default definePlugin({
}
},
renderIgnore(channel) {
const handeClick = () => {
ignoredChannelIds.add(channel.id);
};
return (
<ErrorBoundary>
<span onClick={handeClick} style={{ textAlign: "center", color: "var(--text-danger)" }}>Ignore</span>
<span
className={cl("render")}
onClick={() => ignoredChannelIds.push(channel.id)}
>
Ignore
</span>
</ErrorBoundary >
);
},
contextMenus: {
"user-context": ContextMenuPatch,
"gdm-context": ContextMenuPatch,
}
});

View file

@ -0,0 +1,4 @@
.vc-ignore-calls-render {
text-align: center;
color: var(--text-danger);
}