mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-11 00:34:40 -05:00
Shorten timeout for AJAX
This commit is contained in:
parent
458e9d6cc7
commit
17edfd6573
@ -16,7 +16,7 @@ function get_playlist(plid, retries = 5) {
|
|||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('GET', plid_url, true);
|
xhr.open('GET', plid_url, true);
|
||||||
|
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
|
@ -7,7 +7,7 @@ function get_subscriptions(callback, retries = 5) {
|
|||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('GET', '/api/v1/auth/subscriptions', true);
|
xhr.open('GET', '/api/v1/auth/subscriptions', true);
|
||||||
|
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
@ -82,14 +82,8 @@ function create_notification_stream(subscriptions) {
|
|||||||
|
|
||||||
notifications.onerror = function (event) {
|
notifications.onerror = function (event) {
|
||||||
console.log('Something went wrong with notifications, trying to reconnect...');
|
console.log('Something went wrong with notifications, trying to reconnect...');
|
||||||
notifications.close();
|
notifications = { close: function () { } };
|
||||||
setTimeout(function () { get_subscriptions(create_notification_stream) }, 100);
|
setTimeout(function () { get_subscriptions(create_notification_stream) }, 1000);
|
||||||
}
|
|
||||||
|
|
||||||
notifications.ontimeout = function (event) {
|
|
||||||
console.log('Something went wrong with notifications, trying to reconnect...');
|
|
||||||
notifications.close();
|
|
||||||
get_subscriptions(create_notification_stream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifications.stream();
|
notifications.stream();
|
||||||
@ -103,11 +97,11 @@ window.addEventListener('load', function (e) {
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (!localStorage.getItem('stream')) {
|
if (!localStorage.getItem('stream')) {
|
||||||
notifications = true;
|
notifications = { close: function () { } };
|
||||||
get_subscriptions(create_notification_stream);
|
get_subscriptions(create_notification_stream);
|
||||||
localStorage.setItem('stream', true);
|
localStorage.setItem('stream', true);
|
||||||
}
|
}
|
||||||
}, Math.random() * 1000 + 10);
|
}, Math.random() * 1000 + 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('storage', function (e) {
|
window.addEventListener('storage', function (e) {
|
||||||
@ -117,11 +111,11 @@ window.addEventListener('load', function (e) {
|
|||||||
} else {
|
} else {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (!localStorage.getItem('stream')) {
|
if (!localStorage.getItem('stream')) {
|
||||||
notifications = true;
|
notifications = { close: function () { } };
|
||||||
get_subscriptions(create_notification_stream);
|
get_subscriptions(create_notification_stream);
|
||||||
localStorage.setItem('stream', true);
|
localStorage.setItem('stream', true);
|
||||||
}
|
}
|
||||||
}, Math.random() * 1000 + 10);
|
}, Math.random() * 1000 + 50);
|
||||||
}
|
}
|
||||||
} else if (e.key === 'notification_count') {
|
} else if (e.key === 'notification_count') {
|
||||||
var notification_ticker = document.getElementById('notification_ticker');
|
var notification_ticker = document.getElementById('notification_ticker');
|
||||||
|
@ -17,7 +17,7 @@ function subscribe(retries = 5) {
|
|||||||
'&c=' + subscribe_data.ucid;
|
'&c=' + subscribe_data.ucid;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('POST', url, true);
|
xhr.open('POST', url, true);
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ function unsubscribe(retries = 5) {
|
|||||||
'&c=' + subscribe_data.ucid;
|
'&c=' + subscribe_data.ucid;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('POST', url, true);
|
xhr.open('POST', url, true);
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ toggle_theme.addEventListener('click', function () {
|
|||||||
var url = '/toggle_theme?redirect=false';
|
var url = '/toggle_theme?redirect=false';
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('GET', url, true);
|
xhr.open('GET', url, true);
|
||||||
|
|
||||||
set_mode(dark_mode);
|
set_mode(dark_mode);
|
||||||
|
@ -134,7 +134,7 @@ function get_playlist(plid, retries = 5) {
|
|||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('GET', plid_url, true);
|
xhr.open('GET', plid_url, true);
|
||||||
|
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
@ -212,7 +212,7 @@ function get_reddit_comments(retries = 5) {
|
|||||||
'&hl=' + video_data.preferences.locale;
|
'&hl=' + video_data.preferences.locale;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('GET', url, true);
|
xhr.open('GET', url, true);
|
||||||
|
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
@ -289,7 +289,7 @@ function get_youtube_comments(retries = 5) {
|
|||||||
'&thin_mode=' + video_data.preferences.thin_mode;
|
'&thin_mode=' + video_data.preferences.thin_mode;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('GET', url, true);
|
xhr.open('GET', url, true);
|
||||||
|
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
@ -360,7 +360,7 @@ function get_youtube_replies(target, load_more) {
|
|||||||
'&continuation=' + continuation;
|
'&continuation=' + continuation;
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('GET', url, true);
|
xhr.open('GET', url, true);
|
||||||
|
|
||||||
xhr.onreadystatechange = function () {
|
xhr.onreadystatechange = function () {
|
||||||
|
@ -6,7 +6,7 @@ function mark_watched(target) {
|
|||||||
'&id=' + target.getAttribute('data-id');
|
'&id=' + target.getAttribute('data-id');
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('POST', url, true);
|
xhr.open('POST', url, true);
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ function mark_unwatched(target) {
|
|||||||
'&id=' + target.getAttribute('data-id');
|
'&id=' + target.getAttribute('data-id');
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('POST', url, true);
|
xhr.open('POST', url, true);
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ function remove_subscription(target) {
|
|||||||
'&c=' + target.getAttribute('data-ucid');
|
'&c=' + target.getAttribute('data-ucid');
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('POST', url, true);
|
xhr.open('POST', url, true);
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ function revoke_token(target) {
|
|||||||
'&session=' + target.getAttribute('data-session');
|
'&session=' + target.getAttribute('data-session');
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.responseType = 'json';
|
xhr.responseType = 'json';
|
||||||
xhr.timeout = 20000;
|
xhr.timeout = 10000;
|
||||||
xhr.open('POST', url, true);
|
xhr.open('POST', url, true);
|
||||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user