From 4f531b36344390365adc2ddbf0bffec90b8303b7 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Wed, 7 Sep 2022 21:43:48 +0200 Subject: [PATCH] MessageActions: ignore dblclicks if already editing the msg --- src/plugins/messageActions.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/plugins/messageActions.ts b/src/plugins/messageActions.ts index 10969f9f9..2972cbc88 100644 --- a/src/plugins/messageActions.ts +++ b/src/plugins/messageActions.ts @@ -1,6 +1,7 @@ import { addClickListener, removeClickListener } from '../api/MessageEvents'; import definePlugin from "../utils/types"; import { find, findByProps } from "../webpack"; +import { UserStore } from "../webpack/common"; let isDeletePressed = false; const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true); @@ -16,15 +17,15 @@ export default definePlugin({ const { deleteMessage, startEditMessage } = findByProps("deleteMessage"); const { can } = findByProps("can", "initialize"); const { Permissions: { MANAGE_MESSAGES } } = find(m => m.Permissions?.MANAGE_MESSAGES); - const { getCurrentUser } = findByProps("getCurrentUser"); + const { isEditing } = findByProps("isEditing"); document.addEventListener("keydown", keydown); document.addEventListener("keyup", keyup); this.onClick = addClickListener((msg, chan, event) => { - const isMe = msg.author.id === getCurrentUser().id; + const isMe = msg.author.id === UserStore.getCurrentUser().id; if (!isDeletePressed) { - if (isMe && event.detail >= 2) { + if (isMe && event.detail >= 2 && !isEditing(chan.id, msg.id)) { startEditMessage(chan.id, msg.id, msg.content); event.preventDefault(); }