From c6b19d5144bb30d509b6c301293cb652d95e56db Mon Sep 17 00:00:00 2001 From: Paul Lettington Date: Thu, 8 Aug 2019 22:14:28 +0100 Subject: [PATCH] Add keybind for cycling to the next unread window --- client/js/keybinds.js | 26 ++++++++++++++++++++++++++ client/views/windows/help.tpl | 10 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/client/js/keybinds.js b/client/js/keybinds.js index 0e5ef10e..e16043e1 100644 --- a/client/js/keybinds.js +++ b/client/js/keybinds.js @@ -3,6 +3,7 @@ const $ = require("jquery"); const Mousetrap = require("mousetrap"); const utils = require("./utils"); +const {vueApp} = require("./vue"); Mousetrap.bind(["alt+up", "alt+down"], function(e, keys) { const sidebar = $("#sidebar"); @@ -70,6 +71,31 @@ Mousetrap.bind(["alt+shift+up", "alt+shift+down"], function(e, keys) { 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() { + let targetchan; + + outer_loop: for (const network of vueApp.networks) { + for (const chan of network.channels) { + if (chan.highlight) { + targetchan = chan; + break outer_loop; + } + + if (chan.unread && !targetchan) { + targetchan = chan; + } + } + } + + if (targetchan) { + $(`#sidebar .chan[data-id="${targetchan.id}"]`).trigger("click"); + } + + return false; +}); + // Ignored keys which should not automatically focus the input bar const ignoredKeys = { 8: true, // Backspace diff --git a/client/views/windows/help.tpl b/client/views/windows/help.tpl index d9ac6140..aa16dca9 100644 --- a/client/views/windows/help.tpl +++ b/client/views/windows/help.tpl @@ -87,6 +87,16 @@ +
+
+ Alt A + A +
+
+

Switch to the first window with unread messages.

+
+
+
Ctrl K