Commit 034fe900 authored by Skye Yu's avatar Skye Yu

fix: remove setInterval

parent d33ee3bb
...@@ -705,7 +705,6 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -705,7 +705,6 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
for (let i = 0; i < filename.length; i++) fname.push(filename.charCodeAt(i)); for (let i = 0; i < filename.length; i++) fname.push(filename.charCodeAt(i));
let wakeLock = null; let wakeLock = null;
let timer = null;
function visibilitychange() { function visibilitychange() {
let audio = document.getElementById('test_audio'); let audio = document.getElementById('test_audio');
if (!audio) { if (!audio) {
...@@ -721,14 +720,10 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -721,14 +720,10 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
if (document.visibilityState === 'hidden') { if (document.visibilityState === 'hidden') {
console.log('Page is hidden'); console.log('Page is hidden');
audio.play(); audio.play();
timer = setInterval(() => {
console.log("Keeping the page alive...");
}, 1000)
} else { } else {
audio.pause(); audio.pause();
console.log('Page is visible'); console.log('Page is visible');
wakeLock && wakeLock.release(); wakeLock && wakeLock.release();
timer && clearInterval(timer)
} }
} }
...@@ -745,7 +740,6 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress) ...@@ -745,7 +740,6 @@ Jensen.prototype.getFile = async function (filename, length, ondata, onprogress)
const audio = document.getElementById('test_audio'); const audio = document.getElementById('test_audio');
audio && audio.pause() && audio.remove(); audio && audio.pause() && audio.remove();
wakeLock && wakeLock.release(); wakeLock && wakeLock.release();
timer && clearInterval(timer)
console.log('Clear event and task.'); console.log('Clear event and task.');
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment