feat(MessageClickActions): add REPLY to own messages (#677)

- also adds a click timeout to double click (for MS)
This commit is contained in:
Key 2026-01-24 00:53:27 +00:00 • committed by GitHub
parent 276731947c
commit fef2d6dc68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,6 +34,7 @@ const actions: { label: string; value: ClickAction; }[] = [
const doubleClickOwnActions: { label: string; value: ClickAction; }[] = [
{ label: "None", value: "NONE" },
{ label: "Reply", value: "REPLY" },
{ label: "Edit", value: "EDIT" },
{ label: "Quote", value: "QUOTE" },
{ label: "Copy Content", value: "COPY_CONTENT" },
@ -88,6 +89,11 @@ const focusChanged = () => {
}
};
let lastMouseDownTime = 0;
const onMouseDown = () => {
lastMouseDownTime = Date.now();
};
function modifierFromKey(e: KeyboardEvent): Modifier | null {
if (e.key === "Shift") return "SHIFT";
if (e.key === "Control") return "CTRL";
@ -166,6 +172,11 @@ const settings = definePluginSettings({
description: "Timeout to distinguish double/triple clicks (ms)",
default: 300
},
selectionHoldTimeout: {
type: OptionType.NUMBER,
description: "Timeout to allow text selection (ms)",
default: 300
},
quoteWithReply: {
type: OptionType.BOOLEAN,
description: "When quoting, also reply to the message",
@ -453,12 +464,14 @@ export default definePlugin({
start() {
document.addEventListener("keydown", keydown);
document.addEventListener("keyup", keyup);
document.addEventListener("mousedown", onMouseDown);
WindowStore.addChangeListener(focusChanged);
},
stop() {
document.removeEventListener("keydown", keydown);
document.removeEventListener("keyup", keyup);
document.removeEventListener("mousedown", onMouseDown);
WindowStore.removeChangeListener(focusChanged);
if (doubleClickTimeout) {
@ -525,6 +538,8 @@ export default definePlugin({
singleClickTimeout = null;
}
if (Date.now() - lastMouseDownTime > settings.store.selectionHoldTimeout) return;
const executeDoubleClick = () => {
if (channel.guild_id && !PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return;
if (msg.deleted === true) return;