Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pull/4231'
Browse files Browse the repository at this point in the history
  • Loading branch information
brunnre8 committed Feb 19, 2024
2 parents c09f751 + daabb76 commit be3e27a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/components/Windows/Help.vue
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@
</div>
</div>

<div class="help-item">
<div class="subject">
<span v-if="!isApple"><kbd>Alt</kbd> <kbd>Ctrl</kbd> <kbd></kbd></span>
<span v-else><kbd></kbd> <kbd></kbd> <kbd></kbd></span>
</div>
<div class="description">
<p>Switch to the next window with unread messages in the channel list.</p>
</div>
</div>

<div class="help-item">
<div class="subject">
<span v-if="!isApple"><kbd>Alt</kbd> <kbd>Ctrl</kbd> <kbd></kbd></span>
<span v-else><kbd></kbd> <kbd></kbd> <kbd></kbd></span>
</div>
<div class="description">
<p>Switch to the previous window with unread messages in the channel list.</p>
</div>
</div>

<div class="help-item">
<div class="subject">
<span v-if="!isApple"><kbd>Alt</kbd> <kbd>A</kbd></span>
Expand Down
29 changes: 29 additions & 0 deletions client/js/keybinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit be3e27a

Please sign in to comment.