|
|
@ -15,21 +15,21 @@ export default definePlugin({
|
|
|
|
|
|
|
|
|
|
|
|
start() {
|
|
|
|
start() {
|
|
|
|
Dispatcher.subscribe("DELETE_PENDING_REPLY", onDeletePendingReply);
|
|
|
|
Dispatcher.subscribe("DELETE_PENDING_REPLY", onDeletePendingReply);
|
|
|
|
document.addEventListener("keydown", keydown);
|
|
|
|
document.addEventListener("keydown", onKeydown);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
stop() {
|
|
|
|
Dispatcher.unsubscribe("DELETE_PENDING_REPLY", onDeletePendingReply);
|
|
|
|
Dispatcher.unsubscribe("DELETE_PENDING_REPLY", onDeletePendingReply);
|
|
|
|
document.removeEventListener("keydown", keydown);
|
|
|
|
document.removeEventListener("keydown", onKeydown);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let idx = -1;
|
|
|
|
let idx = -1;
|
|
|
|
const onDeletePendingReply = () => {
|
|
|
|
function onDeletePendingReply() {
|
|
|
|
idx = -1;
|
|
|
|
idx = -1;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const keydown = e => {
|
|
|
|
function onKeydown(e: KeyboardEvent) {
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
(!e.ctrlKey && !e.metaKey) ||
|
|
|
|
(!e.ctrlKey && !e.metaKey) ||
|
|
|
|
(e.key !== "ArrowUp" && e.key !== "ArrowDown")
|
|
|
|
(e.key !== "ArrowUp" && e.key !== "ArrowDown")
|
|
|
@ -46,7 +46,7 @@ const keydown = e => {
|
|
|
|
|
|
|
|
|
|
|
|
if (idx > messages.length) idx = messages.length;
|
|
|
|
if (idx > messages.length) idx = messages.length;
|
|
|
|
if (idx < 0) {
|
|
|
|
if (idx < 0) {
|
|
|
|
return Dispatcher.dispatch({
|
|
|
|
return void Dispatcher.dispatch({
|
|
|
|
type: "DELETE_PENDING_REPLY",
|
|
|
|
type: "DELETE_PENDING_REPLY",
|
|
|
|
channelId,
|
|
|
|
channelId,
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -58,4 +58,4 @@ const keydown = e => {
|
|
|
|
message: messages[idx],
|
|
|
|
message: messages[idx],
|
|
|
|
showMentionToggle: channel.guild_id !== null,
|
|
|
|
showMentionToggle: channel.guild_id !== null,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|