mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-02 21:13:32 +00:00
add badge-setting constructor [WIP]
This commit is contained in:
36
app/renderer/js/pages/preference/badge-settings.js
Normal file
36
app/renderer/js/pages/preference/badge-settings.js
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
const { app } = require('electron');
|
||||
|
||||
class BadgeSettings {
|
||||
constructor(messageCount, mainWindow) {
|
||||
this.messageCount = messageCount;
|
||||
this.mainWindow = mainWindow;
|
||||
}
|
||||
|
||||
showBadgeCount(messageCount, mainWindow) {
|
||||
if (process.platform === 'darwin') {
|
||||
app.setBadgeCount(messageCount);
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
if (!mainWindow.isFocused()) {
|
||||
mainWindow.flashFrame(true);
|
||||
}
|
||||
if (messageCount === 0) {
|
||||
mainWindow.setOverlayIcon(null, '');
|
||||
} else {
|
||||
mainWindow.webContentssend('render-taskbar-icon', messageCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hideBadgeCount(mainWindow) {
|
||||
if (process.platform === 'darwin') {
|
||||
app.setBadgeCount(0);
|
||||
}
|
||||
if (process.platform === 'win32') {
|
||||
mainWindow.setOverlayIcon(null, '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = new BadgeSettings();
|
||||
Reference in New Issue
Block a user