Browse Source

Added desktop notification timeout

Closes #897
master
Igor Zhukov 9 years ago
parent
commit
364d43c33b
  1. 25
      app/js/services.js

25
app/js/services.js

@ -2897,6 +2897,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var titleBackup = document.title, var titleBackup = document.title,
titleChanged = false, titleChanged = false,
titleCnt = 0,
titlePromise; titlePromise;
var prevFavicon; var prevFavicon;
@ -2916,8 +2917,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
titleBackup = document.title; titleBackup = document.title;
titlePromise = $interval(function () { titlePromise = $interval(function () {
var time = tsNow(); if (!notificationsCount || ((titleCnt++) % 2)) {
if (!notificationsCount || time % 2000 > 1000) {
if (titleChanged) { if (titleChanged) {
titleChanged = false; titleChanged = false;
document.title = titleBackup; document.title = titleBackup;
@ -3148,14 +3148,22 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}; };
notification.onclose = function () { notification.onclose = function () {
if (!notification.hidden) {
delete notificationsShown[key]; delete notificationsShown[key];
notificationsClear(); notificationsClear();
}
}; };
if (notification.show) { if (notification.show) {
notification.show(); notification.show();
} }
notificationsShown[key] = notification; notificationsShown[key] = notification;
if (!Config.Navigator.mobile) {
setTimeout(function () {
notificationHide(key)
}, 8000);
}
}; };
function playSound (volume) { function playSound (volume) {
@ -3192,6 +3200,19 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
} }
function notificationHide (key) {
var notification = notificationsShown[key];
if (notification) {
try {
if (notification.close) {
notification.hidden = true;
notification.close();
}
} catch (e) {}
delete notificationsCount[key];
}
}
function notificationSoundReset (tag) { function notificationSoundReset (tag) {
delete soundsPlayed[tag]; delete soundsPlayed[tag];
} }

Loading…
Cancel
Save