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

[BUGFIX] Prevent errors on failing system notification

parent 32620a7a
...@@ -84,39 +84,43 @@ module.exports = class Logger { ...@@ -84,39 +84,43 @@ module.exports = class Logger {
*/ */
static displayNotification(_title, _message, _options = {wait: false, timeout: 5000}) { static displayNotification(_title, _message, _options = {wait: false, timeout: 5000}) {
let icon = _options.icon ? _options.icon : 'SGC.svg'; let icon = _options.icon ? _options.icon : 'SGC.svg';
if (process.platform === 'linux') { try {
let notification = freedesktopNotifier.createNotification({ if (process.platform === 'linux') {
summary: _title, let notification = freedesktopNotifier.createNotification({
body: _message, summary: _title,
icon: path.join(__dirname, 'icons', icon), body: _message,
sound: 'dialog-information', icon: path.join(__dirname, 'icons', icon),
timeout: _options.timeout ? _options.timeout : 5000, sound: 'dialog-information',
actions: { timeout: _options.timeout ? _options.timeout : 5000,
default: '' actions: {
} default: ''
}); }
if (_options.link) {
notification.on('action', () => {
open(_options.link);
}); });
} if (_options.link) {
notification.push(); notification.on('action', () => {
} else { open(_options.link);
notifier.notify( });
{ }
title: _title, notification.push();
message: _message, } else {
icon: path.join(__dirname, 'icons', icon.replace('.svg', '.png')), notifier.notify(
sound: true, {
wait: _options.wait, title: _title,
timeout: _options.timeout 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