Skip to content

Commit 78d1ee5

Browse files
committed
Add shorcut to navigate between channels with undread msgs
1 parent ae6bae6 commit 78d1ee5

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

client/components/Windows/Help.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,26 @@
179179
</div>
180180
</div>
181181

182+
<div class="help-item">
183+
<div class="subject">
184+
<span v-if="!isApple"><kbd>Alt</kbd> <kbd>Ctrl</kbd> <kbd>↓</kbd></span>
185+
<span v-else><kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>↓</kbd></span>
186+
</div>
187+
<div class="description">
188+
<p>Switch to the next window with unread messages in the channel list.</p>
189+
</div>
190+
</div>
191+
192+
<div class="help-item">
193+
<div class="subject">
194+
<span v-if="!isApple"><kbd>Alt</kbd> <kbd>Ctrl</kbd> <kbd>↑</kbd></span>
195+
<span v-else><kbd>⌥</kbd> <kbd>⌘</kbd> <kbd>↑</kbd></span>
196+
</div>
197+
<div class="description">
198+
<p>Switch to the previous window with unread messages in the channel list.</p>
199+
</div>
200+
</div>
201+
182202
<div class="help-item">
183203
<div class="subject">
184204
<span v-if="!isApple"><kbd>Alt</kbd> <kbd>A</kbd></span>

client/js/keybinds.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,33 @@ Mousetrap.bind(["alt+shift+up", "alt+shift+down"], function (e, keys) {
8383
return false;
8484
});
8585

86+
// Switch to the next/previous unread chat
87+
Mousetrap.bind(["alt+mod+up", "alt+mod+down"], function (e, keys) {
88+
if (isIgnoredKeybind(e)) {
89+
return true;
90+
}
91+
92+
const channels = store.state.networks
93+
.map((net) =>
94+
net.channels.filter((chan) => chan.unread || chan === store.state.activeChannel.channel)
95+
)
96+
.flat();
97+
98+
if (channels.length === 0) {
99+
return;
100+
}
101+
102+
let index = channels.findIndex((chan) => chan === store.state.activeChannel.channel);
103+
104+
const length = channels.length;
105+
const direction = keys.split("+").pop() === "up" ? -1 : 1;
106+
index = (((index + direction) % length) + length) % length;
107+
108+
jumpToChannel(channels[index]);
109+
110+
return false;
111+
});
112+
86113
// Jump to the first window with a highlight in it, or the first with unread
87114
// activity if there are none with highlights.
88115
Mousetrap.bind(["alt+a"], function (e) {

0 commit comments

Comments
 (0)