From d9b014e3eb54256bf9cd858b7a6e2ccf4c855dd0 Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Sat, 13 Sep 2025 21:39:23 -0400 Subject: [PATCH] IgnoreCalls: Permanent Ignores --- src/equicordplugins/ignoreCalls/index.tsx | 78 ++++++++++++++-------- src/equicordplugins/ignoreCalls/styles.css | 1 + src/plugins/noBlockedMessages/index.ts | 5 +- src/plugins/quickReply/index.ts | 2 +- 4 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/equicordplugins/ignoreCalls/index.tsx b/src/equicordplugins/ignoreCalls/index.tsx index cf0bbe966..39fc8a958 100644 --- a/src/equicordplugins/ignoreCalls/index.tsx +++ b/src/equicordplugins/ignoreCalls/index.tsx @@ -4,52 +4,73 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ +import "./styles.css"; + 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, { makeRange, OptionType } from "@utils/types"; +import definePlugin, { OptionType } from "@utils/types"; import { Channel } from "@vencord/discord-types"; import { FluxDispatcher, Menu, React, UserStore } from "@webpack/common"; -const ignoredChannelIds: string[] = []; +const ignoredChannelIds = new Set(); 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.includes(channel.id)); + const permanentlyIgnoredUsers = settings.store.permanentlyIgnoredUsers.split(",").map(s => s.trim()).filter(Boolean); + + const [tempChecked, setTempChecked] = React.useState(ignoredChannelIds.has(channel.id)); + const [permChecked, setPermChecked] = React.useState(permanentlyIgnoredUsers.includes(channel.id)); children.push( - , - { - if (checked) - ignoredChannelIds.includes(channel.id); - else - ignoredChannelIds.push(channel.id); + <> + + { + if (tempChecked) + ignoredChannelIds.delete(channel.id); + else + ignoredChannelIds.add(channel.id); + setTempChecked(!tempChecked); + }} + /> + { + let updated = permanentlyIgnoredUsers.slice(); + if (permChecked) { + updated = updated.filter(id => id !== channel.id); + } else { + updated.push(channel.id); + } + settings.store.permanentlyIgnoredUsers = updated.join(", "); - setChecked(!checked); - }} - > + setPermChecked(!permChecked); + }} + /> + ); }; -const settings = definePluginSettings({ - ignoreTimeout: { - type: OptionType.SLIDER, - description: "Timeout to click ignore", - markers: makeRange(0, 10000, 1000), - default: 5000, - stickToMarkers: true, - } -}); +const settings = definePluginSettings({ + permanentlyIgnoredUsers: { + type: OptionType.STRING, + description: "User IDs (comma + space) who should be permanetly ignored", + restartNeeded: true, + default: "", + }, +}); export default definePlugin({ name: "IgnoreCalls", @@ -71,8 +92,9 @@ export default definePlugin({ }, flux: { async CALL_UPDATE({ channelId, ringing, messageId, region }: { channelId: string; ringing: string[]; messageId: string; region: string; }) { + const permanentlyIgnoredUsers = settings.store.permanentlyIgnoredUsers.split(",").map(s => s.trim()).filter(Boolean); setTimeout(() => { - if (!ignoredChannelIds.includes(channelId)) return; + if (!ignoredChannelIds.has(channelId) && !permanentlyIgnoredUsers.includes(channelId)) return; const currentUserId = UserStore.getCurrentUser().id; if (ringing.includes(currentUserId)) { return FluxDispatcher.dispatch({ @@ -83,7 +105,7 @@ export default definePlugin({ region }); } - }, settings.store.ignoreTimeout); + }, 30000); } }, renderIgnore(channel) { @@ -91,7 +113,7 @@ export default definePlugin({ ignoredChannelIds.push(channel.id)} + onClick={() => ignoredChannelIds.add(channel.id)} > Ignore diff --git a/src/equicordplugins/ignoreCalls/styles.css b/src/equicordplugins/ignoreCalls/styles.css index 84d3fd842..1428a3178 100644 --- a/src/equicordplugins/ignoreCalls/styles.css +++ b/src/equicordplugins/ignoreCalls/styles.css @@ -1,4 +1,5 @@ .vc-ignore-calls-render { text-align: center; color: var(--text-danger); + margin-bottom: 15px; } \ No newline at end of file diff --git a/src/plugins/noBlockedMessages/index.ts b/src/plugins/noBlockedMessages/index.ts index 62512e75f..951ba2a6e 100644 --- a/src/plugins/noBlockedMessages/index.ts +++ b/src/plugins/noBlockedMessages/index.ts @@ -188,10 +188,7 @@ export default definePlugin({ isBlocked(message: Message) { try { - if (RelationshipStore.isBlocked(message.author.id)) { - return true; - } - + if (RelationshipStore.isBlocked(message.author.id)) return true; return settings.store.alsoHideIgnoredUsers && RelationshipStore.isIgnored(message.author.id); } catch (e) { new Logger("NoBlockedMessages").error("Failed to check if message is blocked or ignored:", e); diff --git a/src/plugins/quickReply/index.ts b/src/plugins/quickReply/index.ts index 215268c6e..ffad86184 100644 --- a/src/plugins/quickReply/index.ts +++ b/src/plugins/quickReply/index.ts @@ -133,7 +133,7 @@ function getNextMessage(isUp: boolean, isReply: boolean) { messages = messages.filter(m => { if (m.deleted) return false; if (!isReply && m.author.id !== meId) return false; // editing only own messages - if (hasNoBlockedMessages && NoBlockedMessagesPlugin.shouldIgnoreMessage(m)) return false; + if (hasNoBlockedMessages && NoBlockedMessagesPlugin.isBlocked(m)) return false; return true; });