Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

fix: clear interval before starting a new one for download log

Christian Feie8e70285bc52
diff --git a/client/main.js b/client/main.js
index ba11e6c..77ca96c 100644
--- a/client/main.js
+++ b/client/main.js
@@ -4,6 +4,7 @@ window.state = {
summarizing: {},
sseConnected: false
}
+let downloadLogTimeoutHandle
window.eventSource = new EventSource('/')
window.eventSource.onopen = () => {
@@ -41,8 +42,10 @@ window.eventSource.onmessage = (message) => {
if (data.type === 'download-log-line' && data.line) {
const $state = document.querySelector('.state')
if (!$state) { return console.warn('missing $state') }
+ if (downloadLogTimeoutHandle) clearTimeout(downloadLogTimeoutHandle)
+
$state.classList.add('updated')
- setTimeout(() => $state.classList.remove('updated'), 30000)
+ downloadLogTimeoutHandle = setTimeout(() => $state.classList.remove('updated'), 10000)
const $downloadLogLines = $state.querySelector(' .lines')
const text = $downloadLogLines.innerText