From a24255bf69ea58ecc9a74bef190505517cb60459 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Wed, 25 Apr 2018 16:31:43 +0530 Subject: [PATCH] Electron-417 (Reposition active notifications whenever the config is updated) (#339) - Reposition active notifications when the config is updated - Fix spectron test cases --- js/notify/electron-notify.js | 32 ++++--------------- .../spectron/notificationPosition.spectron.js | 4 +-- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/js/notify/electron-notify.js b/js/notify/electron-notify.js index 5f25ea96..3142d874 100644 --- a/js/notify/electron-notify.js +++ b/js/notify/electron-notify.js @@ -165,7 +165,12 @@ function updateConfig(customConfig) { if (customConfig.display) { displayId = customConfig.display; } - closeAll(); + // Reposition active notification on config changes + setupConfig(); + moveOneDown(0) + .then(() => { + log.send(logLevels.INFO, 'updateConfig: repositioned '+ activeNotifications.length +' active notification'); + }); } /** @@ -739,31 +744,6 @@ function cleanUpInactiveWindow() { inactiveWindows = []; } -/** - * Closes all the notifications and windows - */ -function closeAll() { - // Clear out animation Queue and close windows - animationQueue.clear(); - - let notificationWindows = Array.from(activeNotifications); - - notificationWindows.forEach((window) => { - if (window.displayTimer) { - clearTimeout(window.displayTimer); - } - if (!window.isDestroyed()) { - window.close(); - } - }); - - cleanUpInactiveWindow(); - - // Reset certain vars - nextInsertPos = {}; - activeNotifications = []; -} - module.exports.notify = notify; module.exports.updateConfig = updateConfig; diff --git a/tests/spectron/notificationPosition.spectron.js b/tests/spectron/notificationPosition.spectron.js index 71579225..59f9627a 100644 --- a/tests/spectron/notificationPosition.spectron.js +++ b/tests/spectron/notificationPosition.spectron.js @@ -144,7 +144,7 @@ describe('Tests for Notification position', () => { it('should change notification position to upper-right', (done) => { return app.client .click('#open-config-win') - .windowByIndex(2) + .windowByIndex(3) .click('#upper-right') .click('#ok-button') .windowByIndex(0) @@ -194,7 +194,7 @@ describe('Tests for Notification position', () => { .windowByIndex(0) .click('#notf') .getWindowCount().then((count) => { - expect(count === 3).toBeTruthy(); + expect(count === 4).toBeTruthy(); done(); }).catch((err) => { done.fail(new Error(`notificationPosition failed in getWindowCount with error: ${err}`));