mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-22 23:42:58 +00:00
And enable the import/unambiguous ESLint rule as a check on our
partition between scripts and modules. After this commit, if you add
a new file and get this error:
✖ 1:1 This module could be parsed as a valid script. import/unambiguous
* For a module, add an `import` or `export` declaration to make the
file unambiguously a module (the empty `export {};` declaration
suffices).
* For a script, add the file to the xo overrides section of
package.json that marks it "sourceType": "script", and add a 'use
strict' declaration.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import electron, { app } from 'electron';
|
|
|
|
import * as ConfigUtil from '../../utils/config-util';
|
|
|
|
function showBadgeCount(messageCount: number, mainWindow: electron.BrowserWindow): void {
|
|
if (process.platform === 'win32') {
|
|
updateOverlayIcon(messageCount, mainWindow);
|
|
} else {
|
|
app.badgeCount = messageCount;
|
|
}
|
|
}
|
|
|
|
function hideBadgeCount(mainWindow: electron.BrowserWindow): void {
|
|
if (process.platform === 'win32') {
|
|
mainWindow.setOverlayIcon(null, '');
|
|
} else {
|
|
app.badgeCount = 0;
|
|
}
|
|
}
|
|
|
|
export function updateBadge(badgeCount: number, mainWindow: electron.BrowserWindow): void {
|
|
if (ConfigUtil.getConfigItem('badgeOption', true)) {
|
|
showBadgeCount(badgeCount, mainWindow);
|
|
} else {
|
|
hideBadgeCount(mainWindow);
|
|
}
|
|
}
|
|
|
|
function updateOverlayIcon(messageCount: number, mainWindow: electron.BrowserWindow): void {
|
|
if (!mainWindow.isFocused()) {
|
|
mainWindow.flashFrame(ConfigUtil.getConfigItem('flashTaskbarOnMessage'));
|
|
}
|
|
if (messageCount === 0) {
|
|
mainWindow.setOverlayIcon(null, '');
|
|
} else {
|
|
mainWindow.webContents.send('render-taskbar-icon', messageCount);
|
|
}
|
|
}
|
|
|
|
export function updateTaskbarIcon(data: string, text: string, mainWindow: electron.BrowserWindow): void {
|
|
const img = electron.nativeImage.createFromDataURL(data);
|
|
mainWindow.setOverlayIcon(img, text);
|
|
}
|