From 8ddc6e5a2023fea052a4c4bf424e817991f9a0ab Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Tue, 28 May 2019 17:47:39 -0400 Subject: [PATCH] Promisify gui.notify. Will not run it synchronously, but is nice to have. --- app/lib/ui/index.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/lib/ui/index.js b/app/lib/ui/index.js index 45edd91..b149f13 100644 --- a/app/lib/ui/index.js +++ b/app/lib/ui/index.js @@ -37,15 +37,22 @@ gui.counterUpdate = function (which, raw) { }; gui.notify = function (title, message) { 'use strict'; - notifier.notify({ - title: title, - message: message, - //icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons) - sound: true, // Only Notification Center or Windows Toasters - wait: true // Wait with callback, until user action is taken against notification - }, function (err, response) { - // Response is response from notification - }); + return new Promise((resolve, reject) => { + notifier.notify({ + title: title, + message: message, + //icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons) + sound: true, // Only Notification Center or Windows Toasters + wait: true // Wait with callback, until user action is taken against notification + }, function (err, response) { + // Response is response from notification + if (err) { + log.error(`Error with notification`, err); + return reject(err); + } + return resolve(true); + }); + }) }; gui.updateCam = function (t) { 'use strict';