mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-12 16:13:02 -04:00
MessageClickActions: make delete key detection consistent on lost focus (#3470)
Co-authored-by: Vending Machine <vendicated@riseup.net>
This commit is contained in:
parent
bb106b7c49
commit
bf68a8a3e8
1 changed files with 4 additions and 1 deletions
|
@ -20,7 +20,7 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import { Devs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore } from "@webpack/common";
|
||||
import { FluxDispatcher, PermissionsBits, PermissionStore, UserStore, WindowStore } from "@webpack/common";
|
||||
|
||||
const MessageActions = findByPropsLazy("deleteMessage", "startEditMessage");
|
||||
const EditStore = findByPropsLazy("isEditing", "isEditingAny");
|
||||
|
@ -28,6 +28,7 @@ const EditStore = findByPropsLazy("isEditing", "isEditingAny");
|
|||
let isDeletePressed = false;
|
||||
const keydown = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = true);
|
||||
const keyup = (e: KeyboardEvent) => e.key === "Backspace" && (isDeletePressed = false);
|
||||
const focusChanged = () => !WindowStore.isFocused() && (isDeletePressed = false);
|
||||
|
||||
const settings = definePluginSettings({
|
||||
enableDeleteOnClick: {
|
||||
|
@ -62,11 +63,13 @@ export default definePlugin({
|
|||
start() {
|
||||
document.addEventListener("keydown", keydown);
|
||||
document.addEventListener("keyup", keyup);
|
||||
WindowStore.addChangeListener(focusChanged);
|
||||
},
|
||||
|
||||
stop() {
|
||||
document.removeEventListener("keydown", keydown);
|
||||
document.removeEventListener("keyup", keyup);
|
||||
WindowStore.removeChangeListener(focusChanged);
|
||||
},
|
||||
|
||||
onMessageClick(msg: any, channel, event) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue