|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
var notifications, delivered;
|
|
|
|
|
|
|
|
|
|
function get_subscriptions(callback, failures) {
|
|
|
|
|
function get_subscriptions(callback, failures = 1) {
|
|
|
|
|
if (failures >= 10) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -92,6 +92,20 @@ function create_notification_stream(subscriptions) {
|
|
|
|
|
notifications.stream();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener('load', function (e) {
|
|
|
|
|
localStorage.setItem('notification_count', document.getElementById('notification_count') ? document.getElementById('notification_count').innerText : '0');
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem('stream')) {
|
|
|
|
|
localStorage.removeItem('stream');
|
|
|
|
|
} else {
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
if (!localStorage.getItem('stream')) {
|
|
|
|
|
get_subscriptions(create_notification_stream);
|
|
|
|
|
localStorage.setItem('stream', true);
|
|
|
|
|
}
|
|
|
|
|
}, Math.random() * 1000 + 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.addEventListener('storage', function (e) {
|
|
|
|
|
if (e.key === 'stream' && !e.newValue) {
|
|
|
|
|
if (notifications) {
|
|
|
|
@ -116,20 +130,6 @@ window.addEventListener('storage', function (e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.addEventListener('load', function (e) {
|
|
|
|
|
localStorage.setItem('notification_count', document.getElementById('notification_count') ? document.getElementById('notification_count').innerText : '0');
|
|
|
|
|
|
|
|
|
|
if (localStorage.getItem('stream')) {
|
|
|
|
|
localStorage.removeItem('stream');
|
|
|
|
|
} else {
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
if (!localStorage.getItem('stream')) {
|
|
|
|
|
get_subscriptions(create_notification_stream);
|
|
|
|
|
localStorage.setItem('stream', true);
|
|
|
|
|
}
|
|
|
|
|
}, Math.random() * 1000 + 10);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
window.addEventListener('unload', function (e) {
|
|
|
|
|