forked from cory/tildefriends
ssb: Fix channel cycling key shortcut.
This commit is contained in:
parent
69f4af84db
commit
d51b3da1b4
@ -112,27 +112,25 @@ class TfElement extends LitElement {
|
|||||||
|
|
||||||
keydown(event) {
|
keydown(event) {
|
||||||
if (event.altKey && event.key == 'ArrowUp') {
|
if (event.altKey && event.key == 'ArrowUp') {
|
||||||
this.next_channel(1);
|
this.next_channel(-1);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
} else if (event.altKey && event.key == 'ArrowDown') {
|
} else if (event.altKey && event.key == 'ArrowDown') {
|
||||||
this.next_channel(-1);
|
this.next_channel(1);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next_channel(delta) {
|
next_channel(delta) {
|
||||||
let channel_names = ['', '@'].concat(this.channels);
|
let channel_names = ['', '@', '🔐', ...this.channels.map(x => '#' + x)];
|
||||||
let index = channel_names.indexOf(this.hash.substring(1));
|
let index = channel_names.indexOf(this.hash.substring(1));
|
||||||
if (index != -1) {
|
index = index != -1 ? index + delta : 0;
|
||||||
index += delta;
|
tfrpc.rpc.setHash(
|
||||||
this.set_hash(
|
|
||||||
'#' +
|
'#' +
|
||||||
encodeURIComponent(
|
encodeURIComponent(
|
||||||
channel_names[(index + channel_names.length) % channel_names.length]
|
channel_names[(index + channel_names.length) % channel_names.length]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
set_hash(hash) {
|
set_hash(hash) {
|
||||||
this.hash = decodeURIComponent(hash || '#');
|
this.hash = decodeURIComponent(hash || '#');
|
||||||
|
Loading…
Reference in New Issue
Block a user