2021-01-06 15:41:43 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { BrowserWindow } from 'electron';
|
|
|
|
import { app, ipcMain } from 'electron';
|
2020-06-04 18:16:19 +00:00
|
|
|
|
|
|
|
let bounceId = -1;
|
|
|
|
|
2020-09-03 14:59:24 +00:00
|
|
|
export function init(win: BrowserWindow): void {
|
2020-06-04 18:16:19 +00:00
|
|
|
ipcMain.on('bounce-app-icon-start', (_, isCritical = false) => {
|
|
|
|
if (app.dock) {
|
|
|
|
const type = isCritical ? 'critical' : 'informational';
|
|
|
|
bounceId = app.dock.bounce(type);
|
|
|
|
} else if (win && win.flashFrame) {
|
|
|
|
win.once('focus', () => {
|
|
|
|
win.flashFrame(false);
|
|
|
|
});
|
|
|
|
win.flashFrame(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.on('bounce-app-icon-stop', () => {
|
|
|
|
if (app.dock) {
|
|
|
|
if (bounceId < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
app.dock.cancelBounce(bounceId);
|
|
|
|
bounceId = -1;
|
|
|
|
} else if (win && win.flashFrame) {
|
|
|
|
win.flashFrame(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|