Use lock task only from window
This commit is contained in:
parent
1fd418e83d
commit
1fd19121c0
4
.env
4
.env
@ -1,5 +1,5 @@
|
|||||||
API_ID=1025907
|
API_ID=1025907
|
||||||
API_HASH=452b0359b988148995f22ff0f4229750
|
API_HASH=452b0359b988148995f22ff0f4229750
|
||||||
VERSION=1.5.0
|
VERSION=1.5.0
|
||||||
VERSION_FULL=1.5.0 (226)
|
VERSION_FULL=1.5.0 (227)
|
||||||
BUILD=226
|
BUILD=227
|
||||||
|
@ -139,15 +139,17 @@ export default class SuperMessagePort<
|
|||||||
this.log = logger('MP' + (logSuffix ? '-' + logSuffix : ''));
|
this.log = logger('MP' + (logSuffix ? '-' + logSuffix : ''));
|
||||||
this.debug = DEBUG;
|
this.debug = DEBUG;
|
||||||
|
|
||||||
if('locks' in navigator) {
|
if(typeof(window) !== 'undefined') {
|
||||||
const id = 'lock-' + Date.now() + (Math.random() * 0xFFFF | 0);
|
if('locks' in navigator) {
|
||||||
navigator.locks.request(id, () => new Promise(() => {}));
|
const id = 'lock-' + Date.now() + (Math.random() * 0xFFFF | 0);
|
||||||
this.pushTask(this.createTask('lock', id));
|
navigator.locks.request(id, () => new Promise(() => {}));
|
||||||
} else if(typeof(window) !== 'undefined') {
|
this.pushTask(this.createTask('lock', id));
|
||||||
window.addEventListener('beforeunload', () => {
|
} else {
|
||||||
const task = this.createTask('close', undefined);
|
window.addEventListener('beforeunload', () => {
|
||||||
this.postMessage(undefined, task);
|
const task = this.createTask('close', undefined);
|
||||||
});
|
this.postMessage(undefined, task);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.processTaskMap = {
|
this.processTaskMap = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user