diff options
author | Nico <nico@d3sox.me> | 2022-10-25 10:53:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 10:53:06 +0200 |
commit | 559edbfffe4f694a0e89b9e41b72dd6a74b22f93 (patch) | |
tree | f5bccebc62afa5e9002d0b48e39e8843ad9fdf5b /src/plugins/vcDoubleClick.ts | |
parent | 6c3836240176eb6d174ed01281ff1dcfe5b8def3 (diff) | |
download | Vencord-559edbfffe4f694a0e89b9e41b72dd6a74b22f93.tar.gz Vencord-559edbfffe4f694a0e89b9e41b72dd6a74b22f93.tar.bz2 Vencord-559edbfffe4f694a0e89b9e41b72dd6a74b22f93.zip |
Fix vcDoubleClick, add support for stage channels (#158)
Diffstat (limited to 'src/plugins/vcDoubleClick.ts')
-rw-r--r-- | src/plugins/vcDoubleClick.ts | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/plugins/vcDoubleClick.ts b/src/plugins/vcDoubleClick.ts index f2a33a4..3600ac1 100644 --- a/src/plugins/vcDoubleClick.ts +++ b/src/plugins/vcDoubleClick.ts @@ -27,18 +27,29 @@ const timers = {} as Record<string, { export default definePlugin({ name: "vcDoubleClick", description: "Join VCs via DoubleClick instead of single click", - authors: [Devs.Ven], + authors: [ + Devs.Ven, + Devs.D3SOX, + ], patches: [ { find: "VoiceChannel.renderPopout", - replacement: { - match: /onClick:function\(\)\{(e\.handleClick.+?)}/g, - // hack: this is not a react onClick, it is a custom prop handled by Discord - // thus, replacin this with onDoubleClick won't work and you also cannot check - // e.detail since instead of the event they pass the channel. - // do this timer workaround instead - replace: "onClick:function(){Vencord.Plugins.plugins.vcDoubleClick.schedule(()=>{$1}, e)}", - }, + // hack: these are not React onClick, it is a custom prop handled by Discord + // thus, replacing this with onDoubleClick won't work, and you also cannot check + // e.detail since instead of the event they pass the channel. + // do this timer workaround instead + replacement: [ + // voice channels + { + match: /onClick:(.*)function\(\)\{(e\.handleClick.+?)}/g, + replace: "onClick:$1function(){Vencord.Plugins.plugins.vcDoubleClick.schedule(()=>{$2}, e)}", + }, + // stage channels + { + match: /onClick:(\w+)\?void 0:this\.handleClick,/g, + replace: "onClick:$1?void 0:(...args)=>Vencord.Plugins.plugins.vcDoubleClick.schedule(()=>{this.handleClick(...args);}, args[0]),", + } + ], }, { find: 'className:"channelMention",iconType:(', @@ -50,7 +61,8 @@ export default definePlugin({ ], schedule(cb: () => void, e: any) { - const id = e.props.channel.id as string; + // support from stage and voice channels patch + const id = e?.id ?? e.props.channel.id as string; // use a different counter for each channel const data = (timers[id] ??= { timeout: void 0, i: 0 }); // clear any existing timer |