aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/quickreply.ts
diff options
context:
space:
mode:
authorVen <vendicated@riseup.net>2022-10-13 18:42:35 +0200
committerGitHub <noreply@github.com>2022-10-13 18:42:35 +0200
commita73e10fc779e8480c4c3a4ceec3b74d0d63d0edc (patch)
tree61c410e4fe695fa4a0260718095afb3262c4eb0e /src/plugins/quickreply.ts
parent8817e2dff71f4736f4f8c9011457d20e63ec4ca3 (diff)
downloadVencord-a73e10fc779e8480c4c3a4ceec3b74d0d63d0edc.tar.gz
Vencord-a73e10fc779e8480c4c3a4ceec3b74d0d63d0edc.tar.bz2
Vencord-a73e10fc779e8480c4c3a4ceec3b74d0d63d0edc.zip
quickReply => InteractionKeybinds: now supports edits (#95)
Diffstat (limited to 'src/plugins/quickreply.ts')
-rw-r--r--src/plugins/quickreply.ts61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/plugins/quickreply.ts b/src/plugins/quickreply.ts
deleted file mode 100644
index f1a8451..0000000
--- a/src/plugins/quickreply.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import definePlugin from "../utils/types";
-import { Devs } from "../utils/constants";
-import { FluxDispatcher as Dispatcher } from "../webpack/common";
-import { filters } from "../webpack";
-import { lazyWebpack } from "../utils/misc";
-
-const channelIdModule = lazyWebpack(filters.byProps(["getChannelId"]));
-const channelModule = lazyWebpack(filters.byProps(["getChannel"]));
-const messagesModule = lazyWebpack(filters.byProps(["getRawMessages"]));
-
-export default definePlugin({
- name: "Quickreply",
- authors: [Devs.obscurity],
- description: "Reply to messages faster (ctrl + direction)",
-
- start() {
- Dispatcher.subscribe("DELETE_PENDING_REPLY", onDeletePendingReply);
- document.addEventListener("keydown", onKeydown);
- },
-
- stop() {
- Dispatcher.unsubscribe("DELETE_PENDING_REPLY", onDeletePendingReply);
- document.removeEventListener("keydown", onKeydown);
- },
-});
-
-let idx = -1;
-function onDeletePendingReply() {
- idx = -1;
-}
-
-function onKeydown(e: KeyboardEvent) {
- if (
- (!e.ctrlKey && !e.metaKey) ||
- (e.key !== "ArrowUp" && e.key !== "ArrowDown")
- ) {
- return;
- }
-
- const channelId = channelIdModule.getChannelId();
- const channel = channelModule.getChannel(channelId);
- const messages = messagesModule.getMessages(channelId).toArray().reverse();
-
- if (e.key === "ArrowUp") idx += 1;
- else if (e.key === "ArrowDown") idx = Math.max(-1, idx - 1);
-
- if (idx > messages.length) idx = messages.length;
- if (idx < 0) {
- return void Dispatcher.dispatch({
- type: "DELETE_PENDING_REPLY",
- channelId,
- });
- }
-
- Dispatcher.dispatch({
- type: "CREATE_PENDING_REPLY",
- channel: channel,
- message: messages[idx],
- showMentionToggle: channel.guild_id !== null,
- });
-}