From 729e02b78ece84f22995b66d0622087081b401e6 Mon Sep 17 00:00:00 2001 From: Ndip Helen Date: Sun, 3 Apr 2022 01:02:20 +0100 Subject: [PATCH 1/3] close notifications after a set timeut of 6s or when user navigates from a page --- legacy/app/common/notifications/slider.service.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/legacy/app/common/notifications/slider.service.js b/legacy/app/common/notifications/slider.service.js index ba880fb9b6..e557435eab 100644 --- a/legacy/app/common/notifications/slider.service.js +++ b/legacy/app/common/notifications/slider.service.js @@ -17,6 +17,8 @@ function SliderService($rootScope, $q, $templateRequest) { deferredOpen.promise.then(function () { $rootScope.$emit('slider:open', template, icon, iconClass, scope, closeOnTimeout, showCloseButton, closeOnNavigate, loading, type); }); + + closeOnNavigationOrTimeout(); } function close() { @@ -40,4 +42,17 @@ function SliderService($rootScope, $q, $templateRequest) { } deferredClose.resolve(); } + + function closeOnNavigationOrTimeout() { + setTimeout(() => { + close(); + window.removeEventListener("popstate", sliderClose, false); + }, 6000); + + let sliderClose = () => { + close(); + window.removeEventListener("popstate", sliderClose, false); + } + window.addEventListener("popstate", sliderClose, false); + } } From d6ecd09e972af2790399953277c90a2de673b5da Mon Sep 17 00:00:00 2001 From: helen-ndip <72542706+helen-ndip@users.noreply.github.com> Date: Sun, 3 Apr 2022 14:53:13 +0100 Subject: [PATCH 2/3] fix build issues --- legacy/app/common/notifications/slider.service.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/legacy/app/common/notifications/slider.service.js b/legacy/app/common/notifications/slider.service.js index e557435eab..2b40b41a38 100644 --- a/legacy/app/common/notifications/slider.service.js +++ b/legacy/app/common/notifications/slider.service.js @@ -46,13 +46,13 @@ function SliderService($rootScope, $q, $templateRequest) { function closeOnNavigationOrTimeout() { setTimeout(() => { close(); - window.removeEventListener("popstate", sliderClose, false); + window.removeEventListener('popstate', sliderClose, false); }, 6000); let sliderClose = () => { close(); - window.removeEventListener("popstate", sliderClose, false); + window.removeEventListener('popstate', sliderClose, false); } - window.addEventListener("popstate", sliderClose, false); + window.addEventListener('popstate', sliderClose, false); } } From 322731bbc3a9fd1aecee646237e26d507810de67 Mon Sep 17 00:00:00 2001 From: helen-ndip <72542706+helen-ndip@users.noreply.github.com> Date: Wed, 6 Apr 2022 17:53:16 +0100 Subject: [PATCH 3/3] only close notifications on navigation --- legacy/app/common/notifications/slider.service.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/legacy/app/common/notifications/slider.service.js b/legacy/app/common/notifications/slider.service.js index 2b40b41a38..12fde80b9a 100644 --- a/legacy/app/common/notifications/slider.service.js +++ b/legacy/app/common/notifications/slider.service.js @@ -18,7 +18,7 @@ function SliderService($rootScope, $q, $templateRequest) { $rootScope.$emit('slider:open', template, icon, iconClass, scope, closeOnTimeout, showCloseButton, closeOnNavigate, loading, type); }); - closeOnNavigationOrTimeout(); + closeOnNavigation(); } function close() { @@ -43,12 +43,7 @@ function SliderService($rootScope, $q, $templateRequest) { deferredClose.resolve(); } - function closeOnNavigationOrTimeout() { - setTimeout(() => { - close(); - window.removeEventListener('popstate', sliderClose, false); - }, 6000); - + function closeOnNavigation() { let sliderClose = () => { close(); window.removeEventListener('popstate', sliderClose, false);