mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-26 21:01:30 +02:00
fix missing abort method for link-widget
also remove jQuery.proxy
This commit is contained in:
parent
9dfee3f025
commit
6c641f824b
@ -127,16 +127,16 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
this.websocket = new WebSocket(url);
|
this.websocket = new WebSocket(url);
|
||||||
this.websocket.onopen = jQuery.proxy(function(e)
|
this.websocket.onopen = (e) =>
|
||||||
{
|
{
|
||||||
check_timer = window.setTimeout(check, check_interval);
|
check_timer = window.setTimeout(check, check_interval);
|
||||||
this.websocket.send(JSON.stringify({
|
this.websocket.send(JSON.stringify({
|
||||||
subscribe: tokens,
|
subscribe: tokens,
|
||||||
account_id: parseInt(account_id)
|
account_id: parseInt(account_id)
|
||||||
}));
|
}));
|
||||||
}, this);
|
};
|
||||||
|
|
||||||
this.websocket.onmessage = jQuery.proxy(function(event)
|
this.websocket.onmessage = (event) =>
|
||||||
{
|
{
|
||||||
reconnect_time = min_reconnect_time;
|
reconnect_time = min_reconnect_time;
|
||||||
console.log(event);
|
console.log(event);
|
||||||
@ -148,18 +148,18 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
{
|
{
|
||||||
this.handleResponse({ response: [data]});
|
this.handleResponse({ response: [data]});
|
||||||
}
|
}
|
||||||
}, this);
|
};
|
||||||
|
|
||||||
this.websocket.onerror = jQuery.proxy(function(error)
|
this.websocket.onerror = (error) =>
|
||||||
{
|
{
|
||||||
reconnect_time *= 2;
|
reconnect_time *= 2;
|
||||||
if (reconnect_time > max_reconnect_time) reconnect_time = max_reconnect_time;
|
if (reconnect_time > max_reconnect_time) reconnect_time = max_reconnect_time;
|
||||||
|
|
||||||
console.log(error);
|
console.log(error);
|
||||||
(error||this.handleError({}, error));
|
(error||this.handleError({}, error));
|
||||||
}, this);
|
};
|
||||||
|
|
||||||
this.websocket.onclose = jQuery.proxy(function(event)
|
this.websocket.onclose = (event) =>
|
||||||
{
|
{
|
||||||
if (event.wasClean)
|
if (event.wasClean)
|
||||||
{
|
{
|
||||||
@ -176,9 +176,9 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
console.log('[close] Connection died --> reconnect in '+reconnect_time+'ms');
|
console.log('[close] Connection died --> reconnect in '+reconnect_time+'ms');
|
||||||
if (check_timer) window.clearTimeout(check_timer);
|
if (check_timer) window.clearTimeout(check_timer);
|
||||||
check_timer = null;
|
check_timer = null;
|
||||||
window.setTimeout(jQuery.proxy(this.openWebSocket, this, url, tokens, account_id, error, reconnect_time), reconnect_time);
|
window.setTimeout(() => this.openWebSocket(url, tokens, account_id, error, reconnect_time), reconnect_time);
|
||||||
}
|
}
|
||||||
}, this);
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -231,7 +231,9 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
let promise;
|
let promise;
|
||||||
if (this.async)
|
if (this.async)
|
||||||
{
|
{
|
||||||
promise = (this.egw.window?this.egw.window:window).fetch(url, init)
|
const controller = new AbortController();
|
||||||
|
const signal = controller.signal;
|
||||||
|
promise = (this.egw.window?this.egw.window:window).fetch(url, {...init, ...signal})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw response;
|
throw response;
|
||||||
@ -242,6 +244,9 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd)
|
|||||||
.catch((_err) => {
|
.catch((_err) => {
|
||||||
(error || this.handleError).call(this, _err)
|
(error || this.handleError).call(this, _err)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// offering a simple abort mechanism and compatibility with jQuery.ajax
|
||||||
|
promise.abort = () => controller.abort();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user