mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Fix event listener for notifications.js
This commit is contained in:
parent
485a3e29e7
commit
bbb40aef51
1 changed files with 8 additions and 7 deletions
|
@ -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,13 +80,14 @@ function create_notification_stream(subscriptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications.onerror = function (event) {
|
notifications.addEventListener('error', handle_notification_error);
|
||||||
|
notifications.stream();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_notification_error(event) {
|
||||||
console.log('Something went wrong with notifications, trying to reconnect...');
|
console.log('Something went wrong with notifications, trying to reconnect...');
|
||||||
notifications = { close: function () { } };
|
notifications = { close: function () { } };
|
||||||
setTimeout(function () { get_subscriptions(create_notification_stream) }, 1000);
|
setTimeout(function () { get_subscriptions(create_notification_stream) }, 1000);
|
||||||
}
|
|
||||||
|
|
||||||
notifications.stream();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('load', function (e) {
|
window.addEventListener('load', function (e) {
|
||||||
|
|
Loading…
Reference in a new issue