mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-03 13:33:18 +00:00
macOS: Add dock bouncing effect on macOS.
This PR adds a new setting option of controlling the dock bouncing feature on macOS. Fixes: #510.
This commit is contained in:
@@ -75,11 +75,16 @@ class WebView extends BaseComponent {
|
|||||||
|
|
||||||
this.$el.addEventListener('page-favicon-updated', event => {
|
this.$el.addEventListener('page-favicon-updated', event => {
|
||||||
const { favicons } = event;
|
const { favicons } = event;
|
||||||
|
|
||||||
// This returns a string of favicons URL. If there is a PM counts in unread messages then the URL would be like
|
// This returns a string of favicons URL. If there is a PM counts in unread messages then the URL would be like
|
||||||
// https://chat.zulip.org/static/images/favicon/favicon-pms.png
|
// https://chat.zulip.org/static/images/favicon/favicon-pms.png
|
||||||
if (favicons[0].indexOf('favicon-pms') > 0 && process.platform === 'darwin') {
|
if (favicons[0].indexOf('favicon-pms') > 0 && process.platform === 'darwin') {
|
||||||
// This api is only supported on macOS
|
// This api is only supported on macOS
|
||||||
app.dock.setBadge('●');
|
app.dock.setBadge('●');
|
||||||
|
// bounce the dock
|
||||||
|
if (ConfigUtil.getConfigItem('dockBouncing')) {
|
||||||
|
app.dock.bounce();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,11 @@ class ServerManagerView {
|
|||||||
settingOptions.dndPreviousSettings.flashTaskbarOnMessage = true;
|
settingOptions.dndPreviousSettings.flashTaskbarOnMessage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
// Only available on macOS
|
||||||
|
settingOptions.dockBouncing = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (const i in settingOptions) {
|
for (const i in settingOptions) {
|
||||||
if (ConfigUtil.getConfigItem(i) === null) {
|
if (ConfigUtil.getConfigItem(i) === null) {
|
||||||
ConfigUtil.setConfigItem(i, settingOptions[i]);
|
ConfigUtil.setConfigItem(i, settingOptions[i]);
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ class GeneralSection extends BaseSection {
|
|||||||
<div class="setting-description">Show app unread badge</div>
|
<div class="setting-description">Show app unread badge</div>
|
||||||
<div class="setting-control"></div>
|
<div class="setting-control"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="setting-row" id="dock-bounce-option" style= "display:${process.platform === 'darwin' ? '' : 'none'}">
|
||||||
|
<div class="setting-description">Bounce dock on new private message</div>
|
||||||
|
<div class="setting-control"></div>
|
||||||
|
</div>
|
||||||
<div class="setting-row" id="flash-taskbar-option" style= "display:${process.platform === 'win32' ? '' : 'none'}">
|
<div class="setting-row" id="flash-taskbar-option" style= "display:${process.platform === 'win32' ? '' : 'none'}">
|
||||||
<div class="setting-description">Flash taskbar on new message</div>
|
<div class="setting-description">Flash taskbar on new message</div>
|
||||||
<div class="setting-control"></div>
|
<div class="setting-control"></div>
|
||||||
@@ -121,10 +125,15 @@ class GeneralSection extends BaseSection {
|
|||||||
this.removeCustomCSS();
|
this.removeCustomCSS();
|
||||||
|
|
||||||
// Platform specific settings
|
// Platform specific settings
|
||||||
|
|
||||||
// Flashing taskbar on Windows
|
// Flashing taskbar on Windows
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
this.updateFlashTaskbar();
|
this.updateFlashTaskbar();
|
||||||
}
|
}
|
||||||
|
// Dock bounce on macOS
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
this.updateDockBouncing();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTrayOption() {
|
updateTrayOption() {
|
||||||
@@ -153,6 +162,18 @@ class GeneralSection extends BaseSection {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateDockBouncing() {
|
||||||
|
this.generateSettingOption({
|
||||||
|
$element: document.querySelector('#dock-bounce-option .setting-control'),
|
||||||
|
value: ConfigUtil.getConfigItem('dockBouncing', true),
|
||||||
|
clickHandler: () => {
|
||||||
|
const newValue = !ConfigUtil.getConfigItem('dockBouncing');
|
||||||
|
ConfigUtil.setConfigItem('dockBouncing', newValue);
|
||||||
|
this.updateDockBouncing();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
updateFlashTaskbar() {
|
updateFlashTaskbar() {
|
||||||
this.generateSettingOption({
|
this.generateSettingOption({
|
||||||
$element: document.querySelector('#flash-taskbar-option .setting-control'),
|
$element: document.querySelector('#flash-taskbar-option .setting-control'),
|
||||||
|
|||||||
Reference in New Issue
Block a user