Commit 321f74d8 authored by Dominik Beyer's avatar Dominik Beyer

[BUGFIX] Prevent errors on failing system notification

parent 32620a7a
......@@ -84,39 +84,43 @@ module.exports = class Logger {
*/
static displayNotification(_title, _message, _options = {wait: false, timeout: 5000}) {
let icon = _options.icon ? _options.icon : 'SGC.svg';
if (process.platform === 'linux') {
let notification = freedesktopNotifier.createNotification({
summary: _title,
body: _message,
icon: path.join(__dirname, 'icons', icon),
sound: 'dialog-information',
timeout: _options.timeout ? _options.timeout : 5000,
actions: {
default: ''
}
});
if (_options.link) {
notification.on('action', () => {
open(_options.link);
try {
if (process.platform === 'linux') {
let notification = freedesktopNotifier.createNotification({
summary: _title,
body: _message,
icon: path.join(__dirname, 'icons', icon),
sound: 'dialog-information',
timeout: _options.timeout ? _options.timeout : 5000,
actions: {
default: ''
}
});
}
notification.push();
} else {
notifier.notify(
{
title: _title,
message: _message,
icon: path.join(__dirname, 'icons', icon.replace('.svg', '.png')),
sound: true,
wait: _options.wait,
timeout: _options.timeout
if (_options.link) {
notification.on('action', () => {
open(_options.link);
});
}
notification.push();
} else {
notifier.notify(
{
title: _title,
message: _message,
icon: path.join(__dirname, 'icons', icon.replace('.svg', '.png')),
sound: true,
wait: _options.wait,
timeout: _options.timeout
}
);
if (_options.link) {
notifier.on('click', () => {
open(_options.link);
});
}
);
if (_options.link) {
notifier.on('click', () => {
open(_options.link);
});
}
} catch (e) {
Logger.info('Your operating system does not seem to support desktop notifications.');
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment