diff --git a/src/equicordplugins/ignoreCalls/index.tsx b/src/equicordplugins/ignoreCalls/index.tsx index adfda0bde..cf0bbe966 100644 --- a/src/equicordplugins/ignoreCalls/index.tsx +++ b/src/equicordplugins/ignoreCalls/index.tsx @@ -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(); +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( , @@ -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 ( - Ignore + ignoredChannelIds.push(channel.id)} + > + Ignore + ); - }, - contextMenus: { - "user-context": ContextMenuPatch, - "gdm-context": ContextMenuPatch, } }); diff --git a/src/equicordplugins/ignoreCalls/styles.css b/src/equicordplugins/ignoreCalls/styles.css new file mode 100644 index 000000000..84d3fd842 --- /dev/null +++ b/src/equicordplugins/ignoreCalls/styles.css @@ -0,0 +1,4 @@ +.vc-ignore-calls-render { + text-align: center; + color: var(--text-danger); +} \ No newline at end of file