diff --git a/src/equicordplugins/ignoreCalls/index.tsx b/src/equicordplugins/ignoreCalls/index.tsx index adfda0bde..39fc8a958 100644 --- a/src/equicordplugins/ignoreCalls/index.tsx +++ b/src/equicordplugins/ignoreCalls/index.tsx @@ -4,8 +4,11 @@ * 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, { OptionType } from "@utils/types"; @@ -13,46 +16,67 @@ import { Channel } from "@vencord/discord-types"; import { FluxDispatcher, Menu, React, UserStore } from "@webpack/common"; 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.has(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.delete(channel.id); - else - ignoredChannelIds.add(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: [0, 1000, 2500, 5000, 10000], - default: 2500, - 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", description: "Allows you to ignore calls from specific users or dm groups.", authors: [EquicordDevs.TheArmagan], + settings, patches: [ { find: "#{intl::INCOMING_CALL_ELLIPSIS}", @@ -62,11 +86,15 @@ 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; }) { + const permanentlyIgnoredUsers = settings.store.permanentlyIgnoredUsers.split(",").map(s => s.trim()).filter(Boolean); setTimeout(() => { - if (!ignoredChannelIds.has(channelId)) return; + if (!ignoredChannelIds.has(channelId) && !permanentlyIgnoredUsers.includes(channelId)) return; const currentUserId = UserStore.getCurrentUser().id; if (ringing.includes(currentUserId)) { return FluxDispatcher.dispatch({ @@ -77,21 +105,19 @@ export default definePlugin({ region }); } - }, settings.store.ignoreTimeout); + }, 30000); } }, renderIgnore(channel) { - const handeClick = () => { - ignoredChannelIds.add(channel.id); - }; return ( - Ignore + ignoredChannelIds.add(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..1428a3178 --- /dev/null +++ b/src/equicordplugins/ignoreCalls/styles.css @@ -0,0 +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/_core/supportHelper.tsx b/src/plugins/_core/supportHelper.tsx index 47601741a..a40ec11e8 100644 --- a/src/plugins/_core/supportHelper.tsx +++ b/src/plugins/_core/supportHelper.tsx @@ -164,7 +164,9 @@ function generatePluginList() { content += `**Enabled UserPlugins (${enabledUserPlugins.length}):**\n${makeCodeblock(enabledUserPlugins.join(", "))}`; } - if (enabledPlugins.length > 100 && !(isPluginDev(UserStore.getCurrentUser()?.id) || isEquicordPluginDev(UserStore.getCurrentUser()?.id))) { + const user = UserStore.getCurrentUser(); + + if (enabledPlugins.length > 100 && !(isPluginDev(user.id) || isEquicordPluginDev(user.id))) { Alerts.show({ title: "You are attempting to get support!", body:
@@ -181,7 +183,7 @@ function generatePluginList() {
}); - return "You have more than 100 plugins enabled, please reduce the number of enabled plugins to get support."; + return `${user.username} have more than 100 plugins enabled, please reduce the number of enabled plugins to get support.`; } return content; 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; });