vcDoubleClick: don't require dbl click on active vc, fix stage channels (#172)

This commit is contained in:
Nico 2022-10-30 18:47:12 +01:00 committed by GitHub
parent 3af9a14a0e
commit a43a41f61f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@
import { Devs } from "../utils/constants";
import definePlugin from "../utils/types";
import { SelectedChannelStore } from "../webpack/common";
const timers = {} as Record<string, {
timeout?: NodeJS.Timeout;
@ -46,8 +47,8 @@ export default definePlugin({
},
// 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]),",
match: /onClick:(.{0,15})this\.handleClick,/g,
replace: "onClick:$1(...args)=>Vencord.Plugins.plugins.vcDoubleClick.schedule(()=>{this.handleClick(...args);}, args[0]),",
}
],
},
@ -63,6 +64,10 @@ export default definePlugin({
schedule(cb: () => void, e: any) {
// support from stage and voice channels patch
const id = e?.id ?? e.props.channel.id as string;
if (SelectedChannelStore.getVoiceChannelId() === id) {
cb();
return;
}
// use a different counter for each channel
const data = (timers[id] ??= { timeout: void 0, i: 0 });
// clear any existing timer