From daabb7678172fc6b6d7c6eebc6fad40b6f84ea39 Mon Sep 17 00:00:00 2001 From: Nachtalb Date: Thu, 20 May 2021 20:46:24 +0200 Subject: [PATCH] Add shorcut to navigate between channels with undread msgs --- client/components/Windows/Help.vue | 20 ++++++++++++++++++++ client/js/keybinds.ts | 29 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/client/components/Windows/Help.vue b/client/components/Windows/Help.vue index 2ee7ea3e..d0715a2e 100644 --- a/client/components/Windows/Help.vue +++ b/client/components/Windows/Help.vue @@ -179,6 +179,26 @@ +
+
+ Alt Ctrl + +
+
+

Switch to the next window with unread messages in the channel list.

+
+
+ +
+
+ Alt Ctrl + +
+
+

Switch to the previous window with unread messages in the channel list.

+
+
+
Alt A diff --git a/client/js/keybinds.ts b/client/js/keybinds.ts index 88ec48f7..079f293e 100644 --- a/client/js/keybinds.ts +++ b/client/js/keybinds.ts @@ -83,6 +83,35 @@ Mousetrap.bind(["alt+shift+up", "alt+shift+down"], function (e, keys) { return false; }); +// Switch to the next/previous unread chat +Mousetrap.bind(["alt+mod+up", "alt+mod+down"], function (e, keys) { + if (isIgnoredKeybind(e)) { + return true; + } + + const channels = store.state.networks + .map((net) => + net.channels.filter( + (chan) => chan.unread || chan === store.state.activeChannel?.channel + ) + ) + .flat(); + + if (channels.length === 0) { + return; + } + + let index = channels.findIndex((chan) => chan === store.state.activeChannel?.channel); + + const length = channels.length; + const direction = keys.split("+").pop() === "up" ? -1 : 1; + index = (((index + direction) % length) + length) % length; + + jumpToChannel(channels[index]); + + return false; +}); + // Jump to the first window with a highlight in it, or the first with unread // activity if there are none with highlights. Mousetrap.bind(["alt+a"], function (e) {