Use cookie service and small cleanup for pr
This commit is contained in:
parent
2d3583fb44
commit
6fe579119b
3 changed files with 19 additions and 20 deletions
|
@ -3,9 +3,9 @@
|
|||
* in the sidebar) and provides helper methods for working with them.
|
||||
*/
|
||||
angular.module('quay').factory('NotificationService',
|
||||
['$rootScope', '$interval', 'UserService', 'ApiService', 'StringBuilderService', 'PlanService', 'UserService', 'Features', 'Config', '$location', 'VulnerabilityService',
|
||||
['$rootScope', '$interval', 'UserService', 'ApiService', 'StringBuilderService', 'PlanService', 'CookieService', 'Features', 'Config', '$location', 'VulnerabilityService',
|
||||
|
||||
function($rootScope, $interval, UserService, ApiService, StringBuilderService, PlanService, UserService, Features, Config, $location, VulnerabilityService) {
|
||||
function($rootScope, $interval, UserService, ApiService, StringBuilderService, PlanService, CookieService, Features, Config, $location, VulnerabilityService) {
|
||||
var notificationService = {
|
||||
'user': null,
|
||||
'notifications': [],
|
||||
|
@ -267,8 +267,7 @@ function($rootScope, $interval, UserService, ApiService, StringBuilderService, P
|
|||
notificationService.additionalNotifications = resp['additional'];
|
||||
notificationService.notificationClasses = notificationService.getClasses(notificationService.notifications);
|
||||
|
||||
if (notificationService.notifications.length > 0 && localStorage.getItem('quay.enabledDesktopNotifications') === 'on') {
|
||||
console.log(notificationService);
|
||||
if (notificationService.notifications.length > 0 && CookieService.get('quay.enabledDesktopNotifications') === 'on') {
|
||||
notificationService.sendBrowserNotifications();
|
||||
}
|
||||
});
|
||||
|
@ -284,7 +283,7 @@ function($rootScope, $interval, UserService, ApiService, StringBuilderService, P
|
|||
};
|
||||
|
||||
notificationService.sendBrowserNotifications = () => {
|
||||
let mostRecentTimestamp = parseInt(localStorage.getItem('quay.notifications.mostRecentTimestamp'), 10);
|
||||
let mostRecentTimestamp = parseInt(CookieService.get('quay.notifications.mostRecentTimestamp'), 10);
|
||||
if (!mostRecentTimestamp) {
|
||||
mostRecentTimestamp = new Date(notificationService.notifications[0].created).getTime();
|
||||
}
|
||||
|
@ -300,12 +299,12 @@ function($rootScope, $interval, UserService, ApiService, StringBuilderService, P
|
|||
}
|
||||
|
||||
new Notification(message, {
|
||||
icon: 'http://quay.io/static/img/quay-logo.png',
|
||||
image: 'http://quay.io/static/img/quay-logo.png',
|
||||
icon: window.location.origin + '/static/img/quay-logo.png',
|
||||
image: window.location.origin + '/static/img/quay-logo.png',
|
||||
});
|
||||
|
||||
const newTimestamp = new Date(newNotifications[0].created).getTime();
|
||||
localStorage.setItem('quay.notifications.mostRecentTimestamp', newTimestamp.toString());
|
||||
CookieService.putPermanent('quay.notifications.mostRecentTimestamp', newTimestamp.toString());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue