diff options
author | Vendicated <vendicated@riseup.net> | 2022-11-07 21:05:33 +0100 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-11-07 21:05:33 +0100 |
commit | 0af4579204fcbabbce239b2fbd4dfef0df58774d (patch) | |
tree | 4e39a537bdd5bfd50ac11ba80bd39288b0bf061b /src/plugins/messageActions.ts | |
parent | 851d07f31a117cf342d09c0886ae0b38ae0c9050 (diff) | |
download | Vencord-0af4579204fcbabbce239b2fbd4dfef0df58774d.tar.gz Vencord-0af4579204fcbabbce239b2fbd4dfef0df58774d.tar.bz2 Vencord-0af4579204fcbabbce239b2fbd4dfef0df58774d.zip |
Add tracer, fix MessageActions slow startup
Diffstat (limited to 'src/plugins/messageActions.ts')
-rw-r--r-- | src/plugins/messageActions.ts | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/plugins/messageActions.ts b/src/plugins/messageActions.ts index 5fe06c0..98c920e 100644 --- a/src/plugins/messageActions.ts +++ b/src/plugins/messageActions.ts @@ -17,9 +17,10 @@ */ import { addClickListener, removeClickListener } from "../api/MessageEvents"; +import { lazyWebpack } from "../utils"; import { Devs } from "../utils/constants"; import definePlugin from "../utils/types"; -import { find, findByProps } from "../webpack"; +import { filters } from "../webpack"; import { UserStore } from "../webpack/common"; let isDeletePressed = false; @@ -33,10 +34,10 @@ export default definePlugin({ dependencies: ["MessageEventsAPI"], start() { - const { deleteMessage, startEditMessage } = findByProps("deleteMessage", "startEditMessage"); - const { can } = findByProps("can", "initialize"); - const { MANAGE_MESSAGES } = find(m => typeof m.MANAGE_MESSAGES === "bigint"); - const { isEditing } = findByProps("isEditing", "isEditingAny"); + const MessageActions = lazyWebpack(filters.byProps("deleteMessage", "startEditMessage")); + const PermissionStore = lazyWebpack(filters.byProps("can", "initialize")); + const Permissions = lazyWebpack(m => typeof m.MANAGE_MESSAGES === "bigint"); + const EditStore = lazyWebpack(filters.byProps("isEditing", "isEditingAny")); document.addEventListener("keydown", keydown); document.addEventListener("keyup", keyup); @@ -44,12 +45,12 @@ export default definePlugin({ this.onClick = addClickListener((msg, chan, event) => { const isMe = msg.author.id === UserStore.getCurrentUser().id; if (!isDeletePressed) { - if (isMe && event.detail >= 2 && !isEditing(chan.id, msg.id)) { - startEditMessage(chan.id, msg.id, msg.content); + if (isMe && event.detail >= 2 && !EditStore.isEditing(chan.id, msg.id)) { + MessageActions.startEditMessage(chan.id, msg.id, msg.content); event.preventDefault(); } - } else if (isMe || can(MANAGE_MESSAGES, chan)) { - deleteMessage(chan.id, msg.id); + } else if (isMe || PermissionStore.can(Permissions.MANAGE_MESSAGES, chan)) { + MessageActions.deleteMessage(chan.id, msg.id); event.preventDefault(); } }); |