Merge branch 'dev'
This commit is contained in:
commit
1937e7ec04
5 changed files with 71 additions and 41 deletions
|
|
@ -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<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 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(
|
||||
<Menu.MenuSeparator />,
|
||||
<Menu.MenuCheckboxItem
|
||||
id="ic-ignore-calls"
|
||||
label="Ignore Calls"
|
||||
checked={checked}
|
||||
action={() => {
|
||||
if (checked)
|
||||
ignoredChannelIds.delete(channel.id);
|
||||
else
|
||||
ignoredChannelIds.add(channel.id);
|
||||
<>
|
||||
<Menu.MenuSeparator />
|
||||
<Menu.MenuCheckboxItem
|
||||
id="vc-ignore-calls-temp"
|
||||
label="Temporarily Ignore Calls"
|
||||
checked={tempChecked}
|
||||
action={() => {
|
||||
if (tempChecked)
|
||||
ignoredChannelIds.delete(channel.id);
|
||||
else
|
||||
ignoredChannelIds.add(channel.id);
|
||||
|
||||
setTempChecked(!tempChecked);
|
||||
}}
|
||||
/>
|
||||
<Menu.MenuCheckboxItem
|
||||
id="vc-ignore-calls-perm"
|
||||
label="Permanently Ignore Calls"
|
||||
checked={permChecked}
|
||||
action={() => {
|
||||
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);
|
||||
}}
|
||||
></Menu.MenuCheckboxItem>
|
||||
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 (
|
||||
<ErrorBoundary>
|
||||
<span onClick={handeClick} style={{ textAlign: "center", color: "var(--text-danger)" }}>Ignore</span>
|
||||
<span
|
||||
className={cl("render")}
|
||||
onClick={() => ignoredChannelIds.add(channel.id)}
|
||||
>
|
||||
Ignore
|
||||
</span>
|
||||
</ErrorBoundary >
|
||||
);
|
||||
},
|
||||
contextMenus: {
|
||||
"user-context": ContextMenuPatch,
|
||||
"gdm-context": ContextMenuPatch,
|
||||
}
|
||||
});
|
||||
|
|
|
|||
5
src/equicordplugins/ignoreCalls/styles.css
Normal file
5
src/equicordplugins/ignoreCalls/styles.css
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
.vc-ignore-calls-render {
|
||||
text-align: center;
|
||||
color: var(--text-danger);
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
|
@ -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: <div>
|
||||
|
|
@ -181,7 +183,7 @@ function generatePluginList() {
|
|||
</div>
|
||||
});
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue