mirror of
https://github.com/PR0M3TH3AN/TORCH.git
synced 2026-10-27 07:51:52 +00:00
perf: debounce dashboard render on websocket events
Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
1bff009a63
commit
fb58408b84
7 files changed
+111
-2
No files matched your search
+14
-2
@@ -559,6 +559,18 @@ function createLockCard(lock, now) {
|
||||
return card;
|
||||
}
|
||||
|
||||
let renderPending = false;
|
||||
function scheduleRender() {
|
||||
if (renderPending) return;
|
||||
renderPending = true;
|
||||
requestAnimationFrame(() => {
|
||||
renderPending = false;
|
||||
if (isAlive() && !document.hidden) {
|
||||
renderLocks();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderLocks() {
|
||||
if (!isAlive()) return;
|
||||
|
||||
@@ -709,12 +721,12 @@ function connectToRelay(url) {
|
||||
}
|
||||
|
||||
appendRawLog(event);
|
||||
renderLocks();
|
||||
scheduleRender();
|
||||
}
|
||||
|
||||
// NIP-01: ["EOSE", subId] — end of stored events
|
||||
if (data[0] === 'EOSE') {
|
||||
renderLocks();
|
||||
scheduleRender();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user