aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNuckyz <61953774+Nuckyz@users.noreply.github.com>2023-03-05 22:39:53 -0300
committerGitHub <noreply@github.com>2023-03-06 02:39:53 +0100
commit36c27f1111d3a56536d21d2bbeade3f44da7eee0 (patch)
treedc0b0b92e6aba9316b37718f6f629390672ae805 /src
parent95db6c32a38b946abf90ebce165de82681159d68 (diff)
downloadVencord-36c27f1111d3a56536d21d2bbeade3f44da7eee0.tar.gz
Vencord-36c27f1111d3a56536d21d2bbeade3f44da7eee0.tar.bz2
Vencord-36c27f1111d3a56536d21d2bbeade3f44da7eee0.zip
VCDoubleClick: Fix applying to non voice channels (#572)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/vcDoubleClick.ts13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts
index 695e8c5..6d124a6 100644
--- a/src/plugins/vcDoubleClick.ts
+++ b/src/plugins/vcDoubleClick.ts
@@ -19,7 +19,7 @@
import { migratePluginSettings } from "@api/settings";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
-import { SelectedChannelStore } from "@webpack/common";
+import { ChannelStore, SelectedChannelStore } from "@webpack/common";
const timers = {} as Record<string, {
timeout?: NodeJS.Timeout;
@@ -50,12 +50,19 @@ export default definePlugin({
// channel mentions
find: ".shouldCloseDefaultModals",
replacement: {
- match: /onClick:(\i)(?=,.{0,30}className:"channelMention")/,
- replace: "onClick:(_vcEv)=>(_vcEv.detail>=2||_vcEv.target.className.includes('MentionText'))&&($1)()",
+ match: /onClick:(\i)(?=,.{0,30}className:"channelMention".+?(\i)\.inContent)/,
+ replace: (_, onClick, props) => ""
+ + `onClick:(vcDoubleClickEvt)=>$self.shouldRunOnClick(vcDoubleClickEvt,${props})&&${onClick}()`,
}
}
],
+ shouldRunOnClick(e: MouseEvent, { channelId }) {
+ const channel = ChannelStore.getChannel(channelId);
+ if (!channel || ![2, 13].includes(channel.type)) return true;
+ return e.detail >= 2;
+ },
+
schedule(cb: () => void, e: any) {
const id = e.props.channel.id as string;
if (SelectedChannelStore.getVoiceChannelId() === id) {