mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-02 21:13:32 +00:00
Provide keyboard shortcut to switch between servers.
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
'use strict';
|
||||
|
||||
const Tab = require(__dirname + '/../components/tab.js');
|
||||
const SystemUtil = require(__dirname + '/../utils/system-util.js');
|
||||
|
||||
const {ipcRenderer} = require('electron');
|
||||
|
||||
class ServerTab extends Tab {
|
||||
template() {
|
||||
return `<div class="tab">
|
||||
<div class="server-tab-badge"></div>
|
||||
<div class="server-tab" style="background-image: url(${this.props.icon});"></div>
|
||||
<div class="server-tab-shortcut">${this.generateShortcutText()}</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
@@ -26,6 +30,27 @@ class ServerTab extends Tab {
|
||||
this.$badge.classList.remove('active');
|
||||
}
|
||||
}
|
||||
|
||||
generateShortcutText() {
|
||||
// Only provide shortcuts for server [0..10]
|
||||
if (this.props.index >= 10) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const shownIndex = this.props.index + 1;
|
||||
|
||||
let cmdKey = '';
|
||||
|
||||
if (SystemUtil.getOS() === 'Mac') {
|
||||
cmdKey = '⌘';
|
||||
} else {
|
||||
cmdKey = '⌃';
|
||||
}
|
||||
|
||||
ipcRenderer.send('register-server-tab-shortcut', shownIndex);
|
||||
|
||||
return `${cmdKey} ${shownIndex}`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ServerTab;
|
||||
|
||||
Reference in New Issue
Block a user