MessageActions: ignore dblclicks if already editing the msg
This commit is contained in:
parent
a72dedb9aa
commit
4f531b3634
1 changed files with 4 additions and 3 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue