|
|
@ -45,7 +45,7 @@ function create_notification_stream(subscriptions) {
|
|
|
|
|
|
|
|
|
|
|
|
notifications.onmessage = function (event) {
|
|
|
|
notifications.onmessage = function (event) {
|
|
|
|
if (!event.id) {
|
|
|
|
if (!event.id) {
|
|
|
|
return
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var notification = JSON.parse(event.data);
|
|
|
|
var notification = JSON.parse(event.data);
|
|
|
@ -80,15 +80,16 @@ function create_notification_stream(subscriptions) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
notifications.onerror = function (event) {
|
|
|
|
notifications.addEventListener('error', handle_notification_error);
|
|
|
|
console.log('Something went wrong with notifications, trying to reconnect...');
|
|
|
|
|
|
|
|
notifications = { close: function () { } };
|
|
|
|
|
|
|
|
setTimeout(function () { get_subscriptions(create_notification_stream) }, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notifications.stream();
|
|
|
|
notifications.stream();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handle_notification_error(event) {
|
|
|
|
|
|
|
|
console.log('Something went wrong with notifications, trying to reconnect...');
|
|
|
|
|
|
|
|
notifications = { close: function () { } };
|
|
|
|
|
|
|
|
setTimeout(function () { get_subscriptions(create_notification_stream) }, 1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('load', function (e) {
|
|
|
|
window.addEventListener('load', function (e) {
|
|
|
|
localStorage.setItem('notification_count', document.getElementById('notification_count') ? document.getElementById('notification_count').innerText : '0');
|
|
|
|
localStorage.setItem('notification_count', document.getElementById('notification_count') ? document.getElementById('notification_count').innerText : '0');
|
|
|
|
|
|
|
|
|
|
|
|