Fix vcDoubleClick, add support for stage channels (#158)
This commit is contained in:
parent
6c38362401
commit
559edbfffe
3 changed files with 28 additions and 14 deletions
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Flex } from "../components/Flex";
|
import { Flex } from "../components/Flex";
|
||||||
|
import { Devs } from "../utils/constants";
|
||||||
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "../utils/modal";
|
import { ModalContent, ModalFooter, ModalHeader, ModalRoot, ModalSize, openModal } from "../utils/modal";
|
||||||
import definePlugin, { OptionType } from "../utils/types";
|
import definePlugin, { OptionType } from "../utils/types";
|
||||||
import { Settings } from "../Vencord";
|
import { Settings } from "../Vencord";
|
||||||
|
@ -41,10 +42,7 @@ export default definePlugin({
|
||||||
name: "Average React Enjoyer",
|
name: "Average React Enjoyer",
|
||||||
id: 1004904120056029256n
|
id: 1004904120056029256n
|
||||||
},
|
},
|
||||||
{
|
Devs.D3SOX,
|
||||||
name: "D3SOX",
|
|
||||||
id: 201052085641281538n
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
options: {
|
options: {
|
||||||
hideUnreads: {
|
hideUnreads: {
|
||||||
|
|
|
@ -27,18 +27,29 @@ const timers = {} as Record<string, {
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "vcDoubleClick",
|
name: "vcDoubleClick",
|
||||||
description: "Join VCs via DoubleClick instead of single click",
|
description: "Join VCs via DoubleClick instead of single click",
|
||||||
authors: [Devs.Ven],
|
authors: [
|
||||||
|
Devs.Ven,
|
||||||
|
Devs.D3SOX,
|
||||||
|
],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "VoiceChannel.renderPopout",
|
find: "VoiceChannel.renderPopout",
|
||||||
replacement: {
|
// hack: these are not React onClick, it is a custom prop handled by Discord
|
||||||
match: /onClick:function\(\)\{(e\.handleClick.+?)}/g,
|
// thus, replacing this with onDoubleClick won't work, and you also cannot check
|
||||||
// hack: this is not a react onClick, it is a custom prop handled by Discord
|
// e.detail since instead of the event they pass the channel.
|
||||||
// thus, replacin this with onDoubleClick won't work and you also cannot check
|
// do this timer workaround instead
|
||||||
// e.detail since instead of the event they pass the channel.
|
replacement: [
|
||||||
// do this timer workaround instead
|
// voice channels
|
||||||
replace: "onClick:function(){Vencord.Plugins.plugins.vcDoubleClick.schedule(()=>{$1}, e)}",
|
{
|
||||||
},
|
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:(',
|
find: 'className:"channelMention",iconType:(',
|
||||||
|
@ -50,7 +61,8 @@ export default definePlugin({
|
||||||
],
|
],
|
||||||
|
|
||||||
schedule(cb: () => void, e: any) {
|
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
|
// use a different counter for each channel
|
||||||
const data = (timers[id] ??= { timeout: void 0, i: 0 });
|
const data = (timers[id] ??= { timeout: void 0, i: 0 });
|
||||||
// clear any existing timer
|
// clear any existing timer
|
||||||
|
|
|
@ -84,5 +84,9 @@ export const Devs = Object.freeze({
|
||||||
Nuckyz: {
|
Nuckyz: {
|
||||||
name: "Nuckyz",
|
name: "Nuckyz",
|
||||||
id: 235834946571337729n
|
id: 235834946571337729n
|
||||||
|
},
|
||||||
|
D3SOX: {
|
||||||
|
name: "D3SOX",
|
||||||
|
id: 201052085641281538n
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue